| 295 | |
| 296 | |
| 297 | size_t WideToUtfSize(const wchar *Src) |
| 298 | { |
| 299 | size_t Size=0; |
| 300 | for (;*Src!=0;Src++) |
| 301 | if (*Src<0x80) |
| 302 | Size++; |
| 303 | else |
| 304 | if (*Src<0x800) |
| 305 | Size+=2; |
| 306 | else |
| 307 | if ((uint)*Src<0x10000) //(uint) to avoid Clang/win "always true" warning for 16-bit wchar_t. |
| 308 | { |
| 309 | if (Src[0]>=0xd800 && Src[0]<=0xdbff && Src[1]>=0xdc00 && Src[1]<=0xdfff) |
| 310 | { |
| 311 | Size+=4; // 4 output bytes for Unicode surrogate pair. |
| 312 | Src++; |
| 313 | } |
| 314 | else |
| 315 | Size+=3; |
| 316 | } |
| 317 | else |
| 318 | if ((uint)*Src<0x200000) //(uint) to avoid Clang/win "always true" warning for 16-bit wchar_t. |
| 319 | Size+=4; |
| 320 | return Size+1; // Include terminating zero. |
| 321 | } |
| 322 | |
| 323 | |
| 324 | bool UtfToWide(const char *Src,wchar *Dest,size_t DestSize) |
nothing calls this directly
no outgoing calls
no test coverage detected