DCL 3.7.4
Loading...
Searching...
No Matches
__strumbs.h File Reference

Go to the source code of this file.

Macros

#define __DCL_UNIX_WCS_H__   20110117
#define MBSTOSTR_ER(mbs, nmbs, str)
#define STRTOMBS(str, mbs)
#define STRTOMBS_ER(str, mbs)

Functions

__DCL_BEGIN_NAMESPACE String __mbstostr (const char *_src, size_t n=(size_t) -1) __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)

Macro Definition Documentation

◆ __DCL_UNIX_WCS_H__

#define __DCL_UNIX_WCS_H__   20110117

Definition at line 2 of file __strumbs.h.

◆ MBSTOSTR_ER

#define MBSTOSTR_ER ( mbs,
nmbs,
str )
Value:
if (__mbstostr_nt(mbs, nmbs, str) == (size_t)-1) { \
errno = EILSEQ; \
return -1; \
}
size_t __mbstostr_nt(const char *_mbs, size_t _nmbs, String &_str)
Definition __strumbs.cpp:25

Definition at line 19 of file __strumbs.h.

19#define MBSTOSTR_ER(mbs, nmbs, str) \
20 if (__mbstostr_nt(mbs, nmbs, str) == (size_t)-1) { \
21 errno = EILSEQ; \
22 return -1; \
23 }

◆ STRTOMBS

#define STRTOMBS ( str,
mbs )
Value:
size_t n##mbs = __strtombs_nt(str, NULL, (size_t)-1); \
char* mbs = NULL; \
if (n##mbs != (size_t)-1) { \
mbs = (char*)alloca((n##mbs + 1) * sizeof(char)); \
n##mbs = __strtombs_nt(str, mbs, n##mbs + 1); \
}
size_t __strtombs_nt(const String &_str, char *_mbs, size_t _nmbs)
Definition __strumbs.cpp:37
#define NULL
Definition Config.h:312

Definition at line 25 of file __strumbs.h.

25#define STRTOMBS(str, mbs) \
26 size_t n##mbs = __strtombs_nt(str, NULL, (size_t)-1); \
27 char* mbs = NULL; \
28 if (n##mbs != (size_t)-1) { \
29 mbs = (char*)alloca((n##mbs + 1) * sizeof(char)); \
30 n##mbs = __strtombs_nt(str, mbs, n##mbs + 1); \
31 }

◆ STRTOMBS_ER

#define STRTOMBS_ER ( str,
mbs )
Value:
STRTOMBS(str, mbs) \
else { \
errno = EILSEQ; \
return -1; \
}
#define STRTOMBS(str, mbs)
Definition __strumbs.h:25

Definition at line 33 of file __strumbs.h.

33#define STRTOMBS_ER(str, mbs) \
34 STRTOMBS(str, mbs) \
35 else { \
36 errno = EILSEQ; \
37 return -1; \
38 }

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 __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