Changeset 31418 in vbox for trunk/include
- Timestamp:
- Aug 5, 2010 5:37:13 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 64483
- Location:
- trunk/include/iprt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/string.h
r31246 r31418 31 31 #include <iprt/assert.h> 32 32 #include <iprt/stdarg.h> 33 #include <iprt/uni.h> /* for RTUNICP_INVALID */34 33 #include <iprt/err.h> /* for VINF_SUCCESS */ 35 34 #if defined(RT_OS_LINUX) && defined(__KERNEL__) … … 68 67 #endif 69 68 69 70 /** @def RT_USE_RTC_3629 71 * When defined the UTF-8 range will stop at 0x10ffff. If not defined, the 72 * range stops at 0x7fffffff. 73 * @remarks Must be defined both when building and using the IPRT. */ 74 #ifdef DOXYGEN_RUNNING 75 # define RT_USE_RTC_3629 76 #endif 77 78 70 79 /** 71 80 * Byte zero the specified object. … … 100 109 */ 101 110 #define RT_BZERO(pv, cb) do { memset((pv), 0, cb); } while (0) 111 102 112 103 113 … … 823 833 * 824 834 * This function will validate the string, and incorrectly encoded UTF-8 825 * strings will be rejected. The primary purpose of this function is to 826 * help allocate buffers for RTStrToLatin1Ex of the correct size. For most 827 * other purposes RTStrCalcLatin1LenEx() should be used. 835 * strings as well as string with codepoints outside the latin-1 range will be 836 * rejected. The primary purpose of this function is to help allocate buffers 837 * for RTStrToLatin1Ex of the correct size. For most other purposes 838 * RTStrCalcLatin1LenEx() should be used. 828 839 * 829 840 * @returns Number of Latin-1 characters. … … 837 848 * 838 849 * This function will validate the string, and incorrectly encoded UTF-8 839 * strings will be rejected. 850 * strings as well as string with codepoints outside the latin-1 range will be 851 * rejected. 840 852 * 841 853 * @returns iprt status code. 842 854 * @param psz The string. 843 * @param cch The max string length. Use RTSTR_MAX to process the entire string. 855 * @param cch The max string length. Use RTSTR_MAX to process the 856 * entire string. 844 857 * @param pcch Where to store the string length. Optional. 845 858 * This is undefined on failure. … … 875 888 * @returns iprt status code. 876 889 * @param pszString UTF-8 string to convert. 877 * @param cchString The maximum size in chars (the type) to convert. The conversion stop 878 * when it reaches cchString or the string terminator ('\\0'). 879 * Use RTSTR_MAX to translate the entire string. 880 * @param ppsz If cch is non-zero, this must either be pointing to pointer to 881 * a buffer of the specified size, or pointer to a NULL pointer. 882 * If *ppsz is NULL or cch is zero a buffer of at least cch items 883 * will be allocated to hold the translated string. 884 * If a buffer was requested it must be freed using RTStrFree(). 885 * @param cch The buffer size in bytes. This includes the terminator. 890 * @param cchString The maximum size in chars (the type) to convert. 891 * The conversion stop when it reaches cchString or 892 * the string terminator ('\\0'). Use RTSTR_MAX to 893 * translate the entire string. 894 * @param ppsz If cch is non-zero, this must either be pointing to 895 * pointer to a buffer of the specified size, or 896 * pointer to a NULL pointer. If *ppsz is NULL or cch 897 * is zero a buffer of at least cch items will be 898 * allocated to hold the translated string. If a 899 * buffer was requested it must be freed using 900 * RTStrFree(). 901 * @param cch The buffer size in bytes. This includes the 902 * terminator. 886 903 * @param pcch Where to store the length of the translated string, 887 904 * excluding the terminator. (Optional) … … 901 918 * @returns iprt status code. 902 919 * @param pszString UTF-8 string to convert. 903 * @param cchString The maximum size in chars (the type) to convert. The conversion stop 904 * when it reaches cchString or the string terminator ('\\0'). 905 * Use RTSTR_MAX to translate the entire string. 906 * @param ppsz If cch is non-zero, this must either be pointing to pointer to 907 * a buffer of the specified size, or pointer to a NULL pointer. 908 * If *ppsz is NULL or cch is zero a buffer of at least cch items 909 * will be allocated to hold the translated string. 910 * If a buffer was requested it must be freed using RTStrFree(). 911 * @param cch The buffer size in bytes. This includes the terminator. 920 * @param cchString The maximum size in chars (the type) to convert. 921 * The conversion stop when it reaches cchString or 922 * the string terminator ('\\0'). Use RTSTR_MAX to 923 * translate the entire string. 924 * @param ppsz If cch is non-zero, this must either be pointing to 925 * pointer to a buffer of the specified size, or 926 * pointer to a NULL pointer. If *ppsz is NULL or cch 927 * is zero a buffer of at least cch items will be 928 * allocated to hold the translated string. If a 929 * buffer was requested it must be freed using 930 * RTStrFree(). 931 * @param cch The buffer size in bytes. This includes the 932 * terminator. 912 933 * @param pcch Where to store the length of the translated string, 913 934 * excluding the terminator. (Optional) … … 952 973 * @returns iprt status code. 953 974 * @param pszString The Latin-1 string to convert. 954 * @param cchString The number of Latin-1 characters to translate from pszString. 955 * The translation will stop when reaching cchString or the terminator ('\\0'). 956 * Use RTSTR_MAX to translate the entire string. 957 * @param ppsz If cch is non-zero, this must either be pointing to a pointer to 958 * a buffer of the specified size, or pointer to a NULL pointer. 959 * If *ppsz is NULL or cch is zero a buffer of at least cch chars 960 * will be allocated to hold the translated string. 961 * If a buffer was requested it must be freed using RTStrFree(). 975 * @param cchString The number of Latin-1 characters to translate from 976 * pszString. The translation will stop when reaching 977 * cchString or the terminator ('\\0'). Use RTSTR_MAX 978 * to translate the entire string. 979 * @param ppsz If cch is non-zero, this must either be pointing to 980 * a pointer to a buffer of the specified size, or 981 * pointer to a NULL pointer. If *ppsz is NULL or cch 982 * is zero a buffer of at least cch chars will be 983 * allocated to hold the translated string. If a 984 * buffer was requested it must be freed using 985 * RTStrFree(). 962 986 * @param cch The buffer size in chars (the type). This includes the terminator. 963 987 * @param pcch Where to store the length of the translated string, … … 978 1002 * @returns iprt status code. 979 1003 * @param pszString The Latin1 string to convert. 980 * @param cchString The number of Latin1 characters to translate from pwszString. 981 * The translation will stop when reaching cchString or the terminator ('\\0'). 982 * Use RTSTR_MAX to translate the entire string. 983 * @param ppsz If cch is non-zero, this must either be pointing to a pointer to 984 * a buffer of the specified size, or pointer to a NULL pointer. 985 * If *ppsz is NULL or cch is zero a buffer of at least cch chars 986 * will be allocated to hold the translated string. 987 * If a buffer was requested it must be freed using RTStrFree(). 988 * @param cch The buffer size in chars (the type). This includes the terminator. 1004 * @param cchString The number of Latin1 characters to translate from 1005 * pwszString. The translation will stop when 1006 * reaching cchString or the terminator ('\\0'). Use 1007 * RTSTR_MAX to translate the entire string. 1008 * @param ppsz If cch is non-zero, this must either be pointing to 1009 * a pointer to a buffer of the specified size, or 1010 * pointer to a NULL pointer. If *ppsz is NULL or cch 1011 * is zero a buffer of at least cch chars will be 1012 * allocated to hold the translated string. If a 1013 * buffer was requested it must be freed using 1014 * RTStrFree(). 1015 * @param cch The buffer size in chars (the type). This includes 1016 * the terminator. 989 1017 * @param pcch Where to store the length of the translated string, 990 1018 * excluding the terminator. (Optional) … … 1005 1033 * RTLatin1ToUtf8Ex() should be used. 1006 1034 * 1007 * @returns Number of char (bytes).1035 * @returns Number of chars (bytes). 1008 1036 * @returns 0 if the string was incorrectly encoded. 1009 1037 * @param psz The Latin-1 string. … … 1017 1045 * @param psz The string. 1018 1046 * @param cch The max string length. Use RTSTR_MAX to process the entire string. 1019 * @param pcch Where to store the string length (in bytes). Optional.1047 * @param pcch Where to store the string length (in bytes). Optional. 1020 1048 * This is undefined on failure. 1021 1049 */ … … 1159 1187 1160 1188 /** 1161 * Get the UTF-8 size in characters of a given Unicode code point. The code 1162 * point is expected to be a valid Unicode one, but not necessarily in the 1163 * range supported by UTF-8. 1164 * 1165 * @returns the size in characters, or zero if there is no UTF-8 encoding 1189 * Get the UTF-8 size in characters of a given Unicode code point. 1190 * 1191 * The code point is expected to be a valid Unicode one, but not necessarily in 1192 * the range supported by UTF-8. 1193 * 1194 * @returns The number of chars (bytes) required to encode the code point, or 1195 * zero if there is no UTF-8 encoding. 1196 * @param CodePoint The unicode code point. 1166 1197 */ 1167 1198 DECLINLINE(size_t) RTStrCpSize(RTUNICP CodePoint) 1168 1199 { 1169 if (CodePoint < 0x 80)1200 if (CodePoint < 0x00000080) 1170 1201 return 1; 1171 if (CodePoint < 0x 800)1202 if (CodePoint < 0x00000800) 1172 1203 return 2; 1173 if (CodePoint < 0x 10000)1204 if (CodePoint < 0x00010000) 1174 1205 return 3; 1175 if (CodePoint < 0x11000) 1206 #ifdef RT_USE_RTC_3629 1207 if (CodePoint < 0x00011000) 1176 1208 return 4; 1209 #else 1210 if (CodePoint < 0x00200000) 1211 return 4; 1212 if (CodePoint < 0x04000000) 1213 return 5; 1214 if (CodePoint < 0x7fffffff) 1215 return 6; 1216 #endif 1177 1217 return 0; 1178 1218 } … … 1293 1333 1294 1334 /** 1295 * Get the Latin-1 size in characters of a given Unicode code point. The code 1296 * point is expected to be a valid Unicode one, but not necessarily in the 1297 * range supported by Latin-1. 1335 * Get the Latin-1 size in characters of a given Unicode code point. 1336 * 1337 * The code point is expected to be a valid Unicode one, but not necessarily in 1338 * the range supported by Latin-1. 1298 1339 * 1299 1340 * @returns the size in characters, or zero if there is no Latin-1 encoding -
trunk/include/iprt/types.h
r31155 r31418 1575 1575 * Unicode Code Point. 1576 1576 */ 1577 typedef uint32_t RTUNICP;1577 typedef uint32_t RTUNICP; 1578 1578 /** Pointer to an Unicode Code Point. */ 1579 typedef RTUNICP *PRTUNICP;1579 typedef RTUNICP *PRTUNICP; 1580 1580 /** Pointer to an Unicode Code Point. */ 1581 typedef const RTUNICP *PCRTUNICP; 1581 typedef const RTUNICP *PCRTUNICP; 1582 /** Max value a RTUNICP type can hold. */ 1583 #define RTUNICP_MAX ( ~(RTUNICP)0 ) 1584 /** Invalid code point. 1585 * This is returned when encountered invalid encodings or invalid 1586 * unicode code points. */ 1587 #define RTUNICP_INVALID ( UINT32_C(0xfffffffe) ) 1582 1588 1583 1589 -
trunk/include/iprt/uni.h
r28878 r31418 45 45 46 46 RT_C_DECLS_BEGIN 47 48 49 /** Max value a RTUNICP type can hold. */50 #define RTUNICP_MAX ( ~(RTUNICP)0 )51 52 /** Invalid code point.53 * This is returned when encountered invalid encodings or invalid54 * unicode code points. */55 #define RTUNICP_INVALID ( 0xfffffffe )56 47 57 48
Note:
See TracChangeset
for help on using the changeset viewer.