Changeset 194 for trunk/src/helpers/nls.c
- Timestamp:
- Jul 28, 2002, 11:48:47 AM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/nls.c
r190 r194 752 752 } 753 753 754 CHAR G_szUpperMap[257]; 755 BOOL G_fUpperMapInited = FALSE; 756 757 /* 758 *@@ InitUpperMap: 759 * initializes the case map for nlsUpper. 760 * 761 *@@added V0.9.20 (2002-07-25) [umoeller] 762 */ 763 764 static VOID InitUpperMap(VOID) 765 { 766 ULONG ul; 767 COUNTRYCODE cc; 768 BOOL fDBCS = nlsDBCS(); 769 770 for (ul = 0; 771 ul < sizeof(G_szUpperMap); 772 ++ul) 773 { 774 G_szUpperMap[ul] = (CHAR)ul; 775 776 if ( (fDBCS) 777 && (G_afLeadByte[ul] != TYPE_SBCS) 778 ) 779 G_szUpperMap[ul] = ' '; 780 } 781 782 G_szUpperMap[256] = '\0'; 783 784 cc.country = 0; // use system country code 785 cc.codepage = 0; // use process default codepage 786 DosMapCase(255, 787 &cc, 788 G_szUpperMap + 1); 789 790 G_fUpperMapInited = TRUE; 791 } 754 792 755 793 /* … … 757 795 * quick hack for upper-casing a string. 758 796 * 759 * This uses DosMapCase with the default system country 760 * code and the process's codepage. WARNING: DosMapCase 761 * is a 16-bit API and therefore quite slow. Use this 762 * with care. 797 * This now returns the length of the given string always 798 * (V0.9.20). 799 * 800 * Remarks: 801 * 802 * -- On the first call, we build a case map table by 803 * calling DosMapCase with the default system country 804 * code and the process's codepage. Since DosMapCase 805 * is terribly slow with all the 16-bit thunking 806 * involved, we can then use our table without having 807 * to use the API ever again. 808 * 809 * -- As a result, if the process codepage changes for 810 * any reason, this function will not pick up the 811 * change. 812 * 813 * -- This has provisions for DBCS, which hopefully 814 * work. 763 815 * 764 816 *@@added V0.9.16 (2001-10-25) [umoeller] 765 */ 766 767 APIRET nlsUpper(PSZ psz, // in/out: string 768 ULONG ulLength) // in: string length; if 0, we run strlen(psz) 769 { 770 COUNTRYCODE cc; 817 *@@changed V0.9.20 (2002-07-25) [umoeller]: speedup, changed prototype 818 */ 819 820 ULONG nlsUpper(PSZ psz) // in/out: string 821 { 822 ULONG ul = 0; 823 824 if (!G_fUpperMapInited) 825 InitUpperMap(); 771 826 772 827 if (psz) 773 828 { 774 if (!ulLength) 775 ulLength = strlen(psz); 776 777 if (ulLength) 778 { 779 cc.country = 0; // use system country code 780 cc.codepage = 0; // use process default codepage 781 return DosMapCase(ulLength, 782 &cc, 783 psz); 784 } 785 } 786 787 return ERROR_INVALID_PARAMETER; 788 } 789 790 829 PSZ p = psz; 830 831 while (*p++ = G_szUpperMap[*p]) 832 ++ul; 833 } 834 835 return ul; 836 } 837 838
Note:
See TracChangeset
for help on using the changeset viewer.