MCPcopy Create free account
hub / github.com/GarageGames/Torque2D / convertUTF16toUTF8

Function convertUTF16toUTF8

engine/source/string/unicode.cc:125–147  ·  view source on GitHub ↗

-----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

123
124//-----------------------------------------------------------------------------
125const 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//-----------------------------------------------------------------------------
150const U32 convertUTF16toUTF32(const UTF16 *unistring, UTF32 *outbuffer, U32 len)

Callers 4

getCopy8Method · 0.70
createCopy8Method · 0.70
updateBuffer8Method · 0.70
setTextMethod · 0.50

Calls 5

oneUTF16toUTF32Function · 0.85
oneUTF32toUTF8Function · 0.85
getMinFunction · 0.85
dStrlenFunction · 0.70
dMemcpyFunction · 0.50

Tested by

no test coverage detected