Changeset 93103 in vbox for trunk/src/VBox/Runtime/common/string
- Timestamp:
- Dec 30, 2021 11:29:37 PM (3 years ago)
- Location:
- trunk/src/VBox/Runtime/common/string
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/utf-16.cpp
r90794 r93103 1187 1187 1188 1188 1189 RTDECL(int) RTUtf16GetCpNExInternal(PCRTUTF16 *ppwsz, size_t *pcwc, PRTUNICP pCp) 1190 { 1191 int rc; 1192 const size_t cwc = *pcwc; 1193 if (cwc > 0) 1194 { 1195 PCRTUTF16 pwsz = *ppwsz; 1196 const RTUTF16 wc = **ppwsz; 1197 1198 /* simple */ 1199 if (wc < 0xd800 || (wc > 0xdfff && wc < 0xfffe)) 1200 { 1201 *pCp = wc; 1202 *pcwc = cwc - 1; 1203 *ppwsz = pwsz + 1; 1204 return VINF_SUCCESS; 1205 } 1206 1207 if (wc < 0xfffe) 1208 { 1209 /* surrogate pair */ 1210 if (wc < 0xdc00) 1211 { 1212 if (cwc >= 2) 1213 { 1214 const RTUTF16 wc2 = pwsz[1]; 1215 if (wc2 >= 0xdc00 && wc2 <= 0xdfff) 1216 { 1217 *pCp = 0x10000 + (((wc & 0x3ff) << 10) | (wc2 & 0x3ff)); 1218 *pcwc = cwc - 2; 1219 *ppwsz = pwsz + 2; 1220 return VINF_SUCCESS; 1221 } 1222 1223 RTStrAssertMsgFailed(("wc=%#08x wc2=%#08x - invalid 2nd char in surrogate pair\n", wc, wc2)); 1224 } 1225 else 1226 RTStrAssertMsgFailed(("wc=%#08x - incomplete surrogate pair\n", wc)); 1227 } 1228 else 1229 RTStrAssertMsgFailed(("wc=%#08x - invalid surrogate pair order\n", wc)); 1230 rc = VERR_INVALID_UTF16_ENCODING; 1231 } 1232 else 1233 { 1234 RTStrAssertMsgFailed(("wc=%#08x - endian indicator\n", wc)); 1235 rc = VERR_CODE_POINT_ENDIAN_INDICATOR; 1236 } 1237 *pcwc = cwc - 1; 1238 *ppwsz = pwsz + 1; 1239 } 1240 else 1241 rc = VERR_END_OF_STRING; 1242 *pCp = RTUNICP_INVALID; 1243 return rc; 1244 } 1245 RT_EXPORT_SYMBOL(RTUtf16GetCpNExInternal); 1246 1247 1189 1248 RTDECL(int) RTUtf16BigGetCpExInternal(PCRTUTF16 *ppwsz, PRTUNICP pCp) 1190 1249 {
Note:
See TracChangeset
for help on using the changeset viewer.