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

#include <Charset.h>

Inheritance diagram for UTF16Encoder:
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 205 of file Charset.h.

Member Function Documentation

◆ toMultiByte()

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

Implements CharsetEncoder.

Definition at line 327 of file CharsetEncoder.cpp.

328{
329 if (_uc != 0xFFFE && !(_uc >= 0xD800 && _uc < 0xE000)) {
330 int count = 0;
331 if (_uc < 0x10000) {
332 if (_mbslen >= 2) {
333 if (__bigEndian) {
334 _mbs[0] = (unsigned char) (_uc >> 8);
335 _mbs[1] = (unsigned char) _uc;
336 }
337 else {
338 _mbs[1] = (unsigned char) (_uc >> 8);
339 _mbs[0] = (unsigned char) _uc;
340 }
341 return count + 2;
342 }
343 else
344 return BUFFER_SMALL;
345 }
346 else if (_uc < 0x110000) {
347 if (_mbslen >= 4) {
348 ucs4_t uc1 = 0xd800 + ((_uc - 0x10000) >> 10);
349 ucs4_t uc2 = 0xdc00 + ((_uc - 0x10000) & 0x3FF);
350 if (__bigEndian) {
351 _mbs[0] = (unsigned char) (uc1 >> 8);
352 _mbs[1] = (unsigned char) uc1;
353 _mbs[2] = (unsigned char) (uc2 >> 8);
354 _mbs[3] = (unsigned char) uc2;
355 }
356 else {
357 _mbs[3] = (unsigned char) (uc1 >> 8);
358 _mbs[2] = (unsigned char) uc1;
359 _mbs[1] = (unsigned char) (uc2 >> 8);
360 _mbs[0] = (unsigned char) uc2;
361 }
362 return count + 4;
363 }
364 else
365 return BUFFER_SMALL;
366 }
367 }
368 return ILLEGAL_UCS4;
369}
__DCL_BEGIN_NAMESPACE typedef uint32_t ucs4_t
Definition Charset.h:29
#define ILLEGAL_UCS4
#define BUFFER_SMALL

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