-----------------------------------------------------------------------------
| 123 | |
| 124 | //----------------------------------------------------------------------------- |
| 125 | const U32 convertUTF16toUTF8( const UTF16 *unistring, UTF8 *outbuffer, U32 len) |
| 126 | { |
| 127 | AssertFatal(len >= 1, "Buffer for unicode conversion must be large enough to hold at least the null terminator."); |
| 128 | PROFILE_START(convertUTF16toUTF8); |
| 129 | U32 walked, nCodeunits, codeunitLen; |
| 130 | UTF32 middleman; |
| 131 | |
| 132 | nCodeunits=0; |
| 133 | while( *unistring != '\0' && nCodeunits + 3 < len ) |
| 134 | { |
| 135 | walked = 1; |
| 136 | middleman = oneUTF16toUTF32(unistring,&walked); |
| 137 | codeunitLen = oneUTF32toUTF8(middleman, &outbuffer[nCodeunits]); |
| 138 | unistring += walked; |
| 139 | nCodeunits += codeunitLen; |
| 140 | } |
| 141 | |
| 142 | nCodeunits = getMin(nCodeunits,len - 1); |
| 143 | outbuffer[nCodeunits] = '\0'; |
| 144 | |
| 145 | PROFILE_END(); |
| 146 | return nCodeunits; |
| 147 | } |
| 148 | |
| 149 | //----------------------------------------------------------------------------- |
| 150 | const U32 convertUTF16toUTF32(const UTF16 *unistring, UTF32 *outbuffer, U32 len) |
no test coverage detected