DCL 4.0
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 8 of file __strumbs.cpp.

10{
11 __DCL_ASSERT(_mbs != NULL);
12 return UTF8Decoder::decode(_mbs, _nmbs);
13}
#define NULL
Definition Config.h:340
#define __DCL_ASSERT(expr)
Definition Object.h:371

◆ __mbstostr_nt()

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

Definition at line 15 of file __strumbs.cpp.

16{
17 try {
18 _str = __mbstostr(_mbs, _nmbs);
19 }
20 catch (CharsetConvertException* cause) {
21 cause->destroy();
22 return -1; // EILSEQ
23 }
24 return _str.length();
25}
__DCL_BEGIN_NAMESPACE String __mbstostr(const char *_mbs, size_t _nmbs) __DCL_THROWS1(CharsetConvertException *)
Definition __strumbs.cpp:8
virtual void destroy()
Definition Exception.cpp:74

◆ __strtombs_nt()

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

Definition at line 27 of file __strumbs.cpp.

28{
29 UTF8Encoder encoder(false);
30 if (_mbs == NULL) {
31 try {
32 return encoder.getEncodedLength(_str, _str.length());
33 }
34 catch (CharsetConvertException* cause) {
35 cause->destroy();
36 return -1; // EILSEQ
37 }
38 }
39
40 const wchar_t* pIn = _str;
41 size_t nInCount = _str.length();
42 size_t nOutCount = _nmbs;
43 int r = encoder.encode(pIn, nInCount, (byte_t*)_mbs, nOutCount);
44 if (r != CS_NOERROR)
45 return -1; // EILSEQ
46
47 if (nOutCount < _nmbs)
48 _mbs[nOutCount] = '\0';
49
50 return nOutCount;
51}
@ CS_NOERROR
Definition Charset.h:61
unsigned char byte_t
Definition Config.h:274
ByteString r