DCL 4.0
Loading...
Searching...
No Matches
UTF8Encoder Class Reference

#include <Charset.h>

Inheritance diagram for UTF8Encoder:
CharsetEncoder Object

Protected Member Functions

virtual int toMultiByte (ucs4_t _uc, byte_t *_mbs, size_t _mbslen)
Protected Member Functions inherited from CharsetEncoder
 CharsetEncoder ()
Protected Member Functions inherited from Object
virtual ~Object ()
 Object ()

Additional Inherited Members

Public Member Functions inherited from Object
virtual String toString () const
virtual void destroy ()
String className () const
bool isInstanceOf (const std::type_info &typeinfo) const
virtual const std::type_info & typeInfo () const

Detailed Description

Definition at line 132 of file Charset.h.

Member Function Documentation

◆ toMultiByte()

int UTF8Encoder::toMultiByte ( ucs4_t _uc,
byte_t * _mbs,
size_t _mbslen )
protectedvirtual

Implements CharsetEncoder.

Definition at line 243 of file CharsetEncoder.cpp.

244{
245 int count;
246 if (_uc < 0x80)
247 count = 1;
248 else if (_uc < 0x800)
249 count = 2;
250 else if (_uc < 0x10000)
251 count = 3;
252 else if (_uc < 0x200000)
253 count = 4;
254 else if (_uc < 0x4000000)
255 count = 5;
256 else if (_uc <= 0x7fffffff)
257 count = 6;
258 else
259 return ILLEGAL_UCS4;
260
261 if (_mbslen < (size_t)count)
262 return BUFFER_SMALL;
263
264 switch (count) { /* note: code falls through cases! */
265 case 6: _mbs[5] = 0x80 | (_uc & 0x3f); _uc = _uc >> 6; _uc |= 0x4000000;
266 case 5: _mbs[4] = 0x80 | (_uc & 0x3f); _uc = _uc >> 6; _uc |= 0x200000;
267 case 4: _mbs[3] = 0x80 | (_uc & 0x3f); _uc = _uc >> 6; _uc |= 0x10000;
268 case 3: _mbs[2] = 0x80 | (_uc & 0x3f); _uc = _uc >> 6; _uc |= 0x800;
269 case 2: _mbs[1] = 0x80 | (_uc & 0x3f); _uc = _uc >> 6; _uc |= 0xc0;
270 case 1: _mbs[0] = _uc;
271 }
272 return count;
273}
#define ILLEGAL_UCS4
#define BUFFER_SMALL

The documentation for this class was generated from the following files: