DCL 3.7.4
Loading...
Searching...
No Matches
__strumbs.cpp File Reference
#include <dcl/Object.h>
#include <dcl/Charset.h>
#include "__strumbs.h"

Go to the source code of this file.

Functions

__DCL_BEGIN_NAMESPACE String __mbstostr (const char *_mbs, size_t _nmbs) __DCL_THROWS1(CharsetConvertException *)
size_t __mbstostr_nt (const char *_mbs, size_t _nmbs, String &_str)
size_t __strtombs_nt (const String &_str, char *_mbs, size_t _nmbs)

Function Documentation

◆ __mbstostr()

__DCL_BEGIN_NAMESPACE String __mbstostr ( const char * _src,
size_t n = (size_t) -1 )

UNIX에서 system call 관련 문자열들에 대한 wchar_t 처리

Definition at line 18 of file __strumbs.cpp.

20{
21 __DCL_ASSERT(_mbs != NULL);
22 return UTF8Decoder::decode(_mbs, _nmbs);
23}
#define NULL
Definition Config.h:312
#define __DCL_ASSERT(expr)
Definition Object.h:394

◆ __mbstostr_nt()

size_t __mbstostr_nt ( const char * _mbs,
size_t _nmbs,
String & _str )

Definition at line 25 of file __strumbs.cpp.

26{
27 try {
28 _str = __mbstostr(_mbs, _nmbs);
29 }
30 catch (CharsetConvertException* cause) {
31 cause->destroy();
32 return -1; // EILSEQ
33 }
34 return _str.length();
35}
__DCL_BEGIN_NAMESPACE String __mbstostr(const char *_mbs, size_t _nmbs) __DCL_THROWS1(CharsetConvertException *)
Definition __strumbs.cpp:18
virtual void destroy()
Definition Exception.cpp:74

◆ __strtombs_nt()

size_t __strtombs_nt ( const String & _str,
char * _mbs,
size_t _nmbs )

Definition at line 37 of file __strumbs.cpp.

38{
39 UTF8Encoder encoder(false);
40 if (_mbs == NULL) {
41 try {
42 return encoder.getEncodedLength(_str, _str.length());
43 }
44 catch (CharsetConvertException* cause) {
45 cause->destroy();
46 return -1; // EILSEQ
47 }
48 }
49
50 const wchar_t* pIn = _str;
51 size_t nInCount = _str.length();
52 size_t nOutCount = _nmbs;
53 int r = encoder.encode(pIn, nInCount, (byte_t*)_mbs, nOutCount);
54 if (r != CS_NOERROR)
55 return -1; // EILSEQ
56
57 if (nOutCount < _nmbs)
58 _mbs[nOutCount] = '\0';
59
60 return nOutCount;
61}
@ CS_NOERROR
Definition Charset.h:66
unsigned char byte_t
Definition Config.h:246
IOException *size_t r
Definition MediaInfo.cpp:82