diff options
Diffstat (limited to 'src/modules/objects/class_file.cpp')
| -rw-r--r-- | src/modules/objects/class_file.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/modules/objects/class_file.cpp b/src/modules/objects/class_file.cpp index 9195f117..98198cd4 100644 --- a/src/modules/objects/class_file.cpp +++ b/src/modules/objects/class_file.cpp @@ -296,8 +296,14 @@ bool KviKvsObject_file::functionputch(KviKvsObjectFunctionCall *c) if (m_pFile) { if (szChar.length()>1)c->warning(__tr2qs("Argument to long, using only first char")); - const char *ch=szChar; - if (m_pFile->putch(ch[0])<0) c->warning(__tr2qs("Write error occured !")); + // FIXME: putch() argument shouldn't be passed via TQString. + char ch = szChar[0].latin1(); + if (!ch && !szChar[0].isNull()) + { + c->warning(__tr2qs("Can't properly handle non-latin-1 characters.")); + ch = '?'; + } + if (m_pFile->putch(ch)<0) c->warning(__tr2qs("Write error occurred!")); } return true; @@ -328,8 +334,14 @@ bool KviKvsObject_file::functionunGetch(KviKvsObjectFunctionCall *c) else { if (szChar.length()>1) c->warning(__tr2qs("Argument to long, using only first char")); - const char *ch=szChar; - if (m_pFile->ungetch(ch[0])<0) c->warning(__tr2qs("An error occured !"));// c->error ? + // FIXME: ungetch() argument shouldn't be passed via TQString. + char ch = szChar[0].latin1(); + if (!ch && !szChar[0].isNull()) + { + c->warning(__tr2qs("Can't properly handle non-latin-1 characters.")); + ch = '?'; + } + if (m_pFile->ungetch(ch)<0) c->warning(__tr2qs("An error occurred!")); } return true; } @@ -365,8 +377,7 @@ bool KviKvsObject_file::functionwriteBlock(KviKvsObjectFunctionCall *c) if (!m_pFile) return true; if(!m_pFile->isOpen()) c->warning(__tr("File is not open !")); - const char *block=szBlock; - int rlen = m_pFile->writeBlock(block, uLen); + int rlen = m_pFile->writeBlock(szBlock.utf8().data(), uLen); c->returnValue()->setInteger(rlen); m_pFile->flush(); return true; |
