| 219 | } |
| 220 | |
| 221 | U32 convertUTF16toUTF8DoubleNULL( const UTF16 *unistring, UTF8 *outbuffer, U32 len) |
| 222 | { |
| 223 | AssertFatal(len >= 1, "Buffer for unicode conversion must be large enough to hold at least the null terminator."); |
| 224 | PROFILE_START(convertUTF16toUTF8DoubleNULL); |
| 225 | U32 walked, nCodeunits, codeunitLen; |
| 226 | UTF32 middleman; |
| 227 | |
| 228 | nCodeunits=0; |
| 229 | while( ! (*unistring == '\0' && *(unistring + 1) == '\0') && nCodeunits + 3 < len ) |
| 230 | { |
| 231 | walked = 1; |
| 232 | middleman = oneUTF16toUTF32(unistring,&walked); |
| 233 | codeunitLen = oneUTF32toUTF8(middleman, &outbuffer[nCodeunits]); |
| 234 | unistring += walked; |
| 235 | nCodeunits += codeunitLen; |
| 236 | } |
| 237 | |
| 238 | nCodeunits = getMin(nCodeunits,len - 1); |
| 239 | outbuffer[nCodeunits] = NULL; |
| 240 | outbuffer[nCodeunits+1] = NULL; |
| 241 | |
| 242 | PROFILE_END(); |
| 243 | return nCodeunits; |
| 244 | } |
| 245 | |
| 246 | //----------------------------------------------------------------------------- |
| 247 | // Functions that convert buffers of unicode code points |
nothing calls this directly
no test coverage detected