forked from mia/Aegisub
Fix occasional truncation problems with Windows-1258
Originally committed to SVN as r4657.
This commit is contained in:
parent
6623239682
commit
d7ad7e861f
1 changed files with 4 additions and 0 deletions
|
@ -282,7 +282,10 @@ size_t IconvWrapper::Convert(const char* source, size_t sourceSize, char *dest,
|
||||||
if (sourceSize == (size_t)-1) {
|
if (sourceSize == (size_t)-1) {
|
||||||
sourceSize = SrcStrLen(source);
|
sourceSize = SrcStrLen(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t res = (*conv)(cd, &source, &sourceSize, &dest, &destSize);
|
size_t res = (*conv)(cd, &source, &sourceSize, &dest, &destSize);
|
||||||
|
if (res == 0) res = (*conv)(cd, NULL, NULL, &dest, &destSize);
|
||||||
|
|
||||||
if (res == iconv_failed) {
|
if (res == iconv_failed) {
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
|
@ -325,6 +328,7 @@ size_t IconvWrapper::RequiredBufferSize(const char* src, size_t srcLen) {
|
||||||
char* dst = buff;
|
char* dst = buff;
|
||||||
size_t dstSize = sizeof(buff);
|
size_t dstSize = sizeof(buff);
|
||||||
res = (*conv)(cd, &src, &srcLen, &dst, &dstSize);
|
res = (*conv)(cd, &src, &srcLen, &dst, &dstSize);
|
||||||
|
(*conv)(cd, NULL, NULL, &dst, &dstSize);
|
||||||
|
|
||||||
charsWritten += dst - buff;
|
charsWritten += dst - buff;
|
||||||
} while (res == iconv_failed && errno == E2BIG);
|
} while (res == iconv_failed && errno == E2BIG);
|
||||||
|
|
Loading…
Reference in a new issue