diff options
Diffstat (limited to 'src/common/utf8.cpp')
| -rw-r--r-- | src/common/utf8.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/common/utf8.cpp b/src/common/utf8.cpp index be4ebc855..66a2f6339 100644 --- a/src/common/utf8.cpp +++ b/src/common/utf8.cpp | |||
| @@ -281,28 +281,28 @@ int u8_read_escape_sequence(const char *str, u32 *dest) | |||
| 281 | do { | 281 | do { |
| 282 | digs[dno++] = str[i++]; | 282 | digs[dno++] = str[i++]; |
| 283 | } while (octal_digit(str[i]) && dno < 3); | 283 | } while (octal_digit(str[i]) && dno < 3); |
| 284 | ch = strtol(digs, NULL, 8); | 284 | ch = strtol(digs, nullptr, 8); |
| 285 | } | 285 | } |
| 286 | else if (str[0] == 'x') { | 286 | else if (str[0] == 'x') { |
| 287 | while (hex_digit(str[i]) && dno < 2) { | 287 | while (hex_digit(str[i]) && dno < 2) { |
| 288 | digs[dno++] = str[i++]; | 288 | digs[dno++] = str[i++]; |
| 289 | } | 289 | } |
| 290 | if (dno > 0) | 290 | if (dno > 0) |
| 291 | ch = strtol(digs, NULL, 16); | 291 | ch = strtol(digs, nullptr, 16); |
| 292 | } | 292 | } |
| 293 | else if (str[0] == 'u') { | 293 | else if (str[0] == 'u') { |
| 294 | while (hex_digit(str[i]) && dno < 4) { | 294 | while (hex_digit(str[i]) && dno < 4) { |
| 295 | digs[dno++] = str[i++]; | 295 | digs[dno++] = str[i++]; |
| 296 | } | 296 | } |
| 297 | if (dno > 0) | 297 | if (dno > 0) |
| 298 | ch = strtol(digs, NULL, 16); | 298 | ch = strtol(digs, nullptr, 16); |
| 299 | } | 299 | } |
| 300 | else if (str[0] == 'U') { | 300 | else if (str[0] == 'U') { |
| 301 | while (hex_digit(str[i]) && dno < 8) { | 301 | while (hex_digit(str[i]) && dno < 8) { |
| 302 | digs[dno++] = str[i++]; | 302 | digs[dno++] = str[i++]; |
| 303 | } | 303 | } |
| 304 | if (dno > 0) | 304 | if (dno > 0) |
| 305 | ch = strtol(digs, NULL, 16); | 305 | ch = strtol(digs, nullptr, 16); |
| 306 | } | 306 | } |
| 307 | *dest = ch; | 307 | *dest = ch; |
| 308 | 308 | ||
| @@ -353,7 +353,7 @@ const char *u8_strchr(const char *s, u32 ch, int *charn) | |||
| 353 | lasti = i; | 353 | lasti = i; |
| 354 | (*charn)++; | 354 | (*charn)++; |
| 355 | } | 355 | } |
| 356 | return NULL; | 356 | return nullptr; |
| 357 | } | 357 | } |
| 358 | 358 | ||
| 359 | const char *u8_memchr(const char *s, u32 ch, size_t sz, int *charn) | 359 | const char *u8_memchr(const char *s, u32 ch, size_t sz, int *charn) |
| @@ -378,7 +378,7 @@ const char *u8_memchr(const char *s, u32 ch, size_t sz, int *charn) | |||
| 378 | lasti = i; | 378 | lasti = i; |
| 379 | (*charn)++; | 379 | (*charn)++; |
| 380 | } | 380 | } |
| 381 | return NULL; | 381 | return nullptr; |
| 382 | } | 382 | } |
| 383 | 383 | ||
| 384 | int u8_is_locale_utf8(const char *locale) | 384 | int u8_is_locale_utf8(const char *locale) |
| @@ -419,35 +419,35 @@ bool UTF8StringHasNonASCII(const char *utf8string) { | |||
| 419 | 419 | ||
| 420 | std::string ConvertWStringToUTF8(const wchar_t *wstr) { | 420 | std::string ConvertWStringToUTF8(const wchar_t *wstr) { |
| 421 | int len = (int)wcslen(wstr); | 421 | int len = (int)wcslen(wstr); |
| 422 | int size = (int)WideCharToMultiByte(CP_UTF8, 0, wstr, len, 0, 0, NULL, NULL); | 422 | int size = (int)WideCharToMultiByte(CP_UTF8, 0, wstr, len, 0, 0, nullptr, nullptr); |
| 423 | std::string s; | 423 | std::string s; |
| 424 | s.resize(size); | 424 | s.resize(size); |
| 425 | if (size > 0) { | 425 | if (size > 0) { |
| 426 | WideCharToMultiByte(CP_UTF8, 0, wstr, len, &s[0], size, NULL, NULL); | 426 | WideCharToMultiByte(CP_UTF8, 0, wstr, len, &s[0], size, nullptr, nullptr); |
| 427 | } | 427 | } |
| 428 | return s; | 428 | return s; |
| 429 | } | 429 | } |
| 430 | 430 | ||
| 431 | std::string ConvertWStringToUTF8(const std::wstring &wstr) { | 431 | std::string ConvertWStringToUTF8(const std::wstring &wstr) { |
| 432 | int len = (int)wstr.size(); | 432 | int len = (int)wstr.size(); |
| 433 | int size = (int)WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), len, 0, 0, NULL, NULL); | 433 | int size = (int)WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), len, 0, 0, nullptr, nullptr); |
| 434 | std::string s; | 434 | std::string s; |
| 435 | s.resize(size); | 435 | s.resize(size); |
| 436 | if (size > 0) { | 436 | if (size > 0) { |
| 437 | WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), len, &s[0], size, NULL, NULL); | 437 | WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), len, &s[0], size, nullptr, nullptr); |
| 438 | } | 438 | } |
| 439 | return s; | 439 | return s; |
| 440 | } | 440 | } |
| 441 | 441 | ||
| 442 | void ConvertUTF8ToWString(wchar_t *dest, size_t destSize, const std::string &source) { | 442 | void ConvertUTF8ToWString(wchar_t *dest, size_t destSize, const std::string &source) { |
| 443 | int len = (int)source.size(); | 443 | int len = (int)source.size(); |
| 444 | int size = (int)MultiByteToWideChar(CP_UTF8, 0, source.c_str(), len, NULL, 0); | 444 | int size = (int)MultiByteToWideChar(CP_UTF8, 0, source.c_str(), len, nullptr, 0); |
| 445 | MultiByteToWideChar(CP_UTF8, 0, source.c_str(), len, dest, std::min((int)destSize, size)); | 445 | MultiByteToWideChar(CP_UTF8, 0, source.c_str(), len, dest, std::min((int)destSize, size)); |
| 446 | } | 446 | } |
| 447 | 447 | ||
| 448 | std::wstring ConvertUTF8ToWString(const std::string &source) { | 448 | std::wstring ConvertUTF8ToWString(const std::string &source) { |
| 449 | int len = (int)source.size(); | 449 | int len = (int)source.size(); |
| 450 | int size = (int)MultiByteToWideChar(CP_UTF8, 0, source.c_str(), len, NULL, 0); | 450 | int size = (int)MultiByteToWideChar(CP_UTF8, 0, source.c_str(), len, nullptr, 0); |
| 451 | std::wstring str; | 451 | std::wstring str; |
| 452 | str.resize(size); | 452 | str.resize(size); |
| 453 | if (size > 0) { | 453 | if (size > 0) { |