#include "geniconv.h"
#include <stdlib.h>
Go to the source code of this file.
◆ StrUTF8()
| int StrUTF8 |
( |
int |
fToUTF8, |
|
|
char * |
pcDst, |
|
|
int |
cbDst, |
|
|
char * |
pcSrc, |
|
|
int |
cbSrc |
|
) |
| |
Definition at line 25 of file sys2utf8.c.
28 char *pcDstStart = pcDst;
30 char *pszToCP, *pszFromCP;
49 rc =
iconv(cd, &pcSrc, (
size_t *)&cbSrc, &pcDst, (
size_t *)&cbDst);
50 if (rc == (
size_t)-1) {
51 if (errno == EILSEQ) {
74 pcDst -= (cbDst == 0)? 2 : 1;
77 *((
short *)pcDst) =
'\0';
80 return (fError) ? -1 : (pcDst - pcDstStart);
iconv_t iconv_open(const char *, const char *)
size_t iconv(iconv_t, char **, size_t *, char **, size_t *)
References iconv(), iconv_close(), and iconv_open().
Referenced by main(), and StrUTF8New().
◆ StrUTF8Free()
| void StrUTF8Free |
( |
char * |
pszStr | ) |
|
◆ StrUTF8New()
| char* StrUTF8New |
( |
int |
fToUTF8, |
|
|
char * |
pcStr, |
|
|
int |
cbStr |
|
) |
| |
Definition at line 83 of file sys2utf8.c.
85 int cbNewStr = (((cbStr > 4)? cbStr : 4) + 1) * 2;
86 char *pszNewStr = (
char *)
malloc(cbNewStr);
88 if (pszNewStr ==
NULL)
91 cbNewStr =
StrUTF8(fToUTF8, pszNewStr, cbNewStr, pcStr, cbStr);
93 pcStr = (
char *) realloc(pszNewStr, cbNewStr + ((fToUTF8)? 1 :
sizeof(
short)));
int StrUTF8(int fToUTF8, char *pcDst, int cbDst, char *pcSrc, int cbSrc)
References free, malloc, NULL, and StrUTF8().
Referenced by main().