mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 02:53:10 +01:00
trunk/branch integration: TextEncoding update
This commit is contained in:
@@ -85,34 +85,28 @@ int StreamConverterBuf::readFromDevice()
|
|||||||
|
|
||||||
poco_assert (c < 256);
|
poco_assert (c < 256);
|
||||||
int uc;
|
int uc;
|
||||||
int n = _inEncoding.characterMap()[c];
|
_buffer [0] = (unsigned char) c;
|
||||||
if (n == -1)
|
int n = _inEncoding.queryConvert(_buffer, 1);
|
||||||
{
|
int read = 1;
|
||||||
uc = _defaultChar;
|
|
||||||
++_errors;
|
while (-1 > n)
|
||||||
}
|
|
||||||
else if (n >= 0)
|
|
||||||
uc = n;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
poco_assert_dbg(-n <= sizeof(_buffer));
|
poco_assert_dbg(-n <= sizeof(_buffer));
|
||||||
_buffer[0] = (unsigned char) c;
|
_pIstr->read((char*) _buffer + read, -n - read);
|
||||||
_pIstr->read((char*) _buffer + 1, -n - 1);
|
read = -n;
|
||||||
if (_pIstr->gcount() == -n - 1)
|
n = _inEncoding.queryConvert(_buffer, -n);
|
||||||
{
|
}
|
||||||
uc = _inEncoding.convert(_buffer);
|
|
||||||
if (uc == -1)
|
if (-1 >= n)
|
||||||
{
|
{
|
||||||
uc = _defaultChar;
|
uc = _defaultChar;
|
||||||
++_errors;
|
++_errors;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uc = _defaultChar;
|
uc = n;
|
||||||
++_errors;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_sequenceLength = _outEncoding.convert(uc, _buffer, sizeof(_buffer));
|
_sequenceLength = _outEncoding.convert(uc, _buffer, sizeof(_buffer));
|
||||||
if (_sequenceLength == 0)
|
if (_sequenceLength == 0)
|
||||||
_sequenceLength = _outEncoding.convert(_defaultChar, _buffer, sizeof(_buffer));
|
_sequenceLength = _outEncoding.convert(_defaultChar, _buffer, sizeof(_buffer));
|
||||||
@@ -127,23 +121,14 @@ int StreamConverterBuf::writeToDevice(char c)
|
|||||||
{
|
{
|
||||||
poco_assert_dbg (_pOstr);
|
poco_assert_dbg (_pOstr);
|
||||||
|
|
||||||
if (_sequenceLength == 0)
|
_buffer[_pos++] = (unsigned char) c;
|
||||||
|
if (_sequenceLength == 0 || _sequenceLength == _pos)
|
||||||
{
|
{
|
||||||
int n = _inEncoding.characterMap()[(unsigned char) c];
|
int n = _inEncoding.queryConvert(_buffer, _pos);
|
||||||
if (n == -1)
|
if (-1 <= n)
|
||||||
{
|
{
|
||||||
++_errors;
|
int uc = n;
|
||||||
return -1;
|
if (-1 == n)
|
||||||
}
|
|
||||||
_buffer[0] = (unsigned char) c;
|
|
||||||
_sequenceLength = n < 0 ? -n : 1;
|
|
||||||
_pos = 1;
|
|
||||||
}
|
|
||||||
else _buffer[_pos++] = (unsigned char) c;
|
|
||||||
if (_pos == _sequenceLength)
|
|
||||||
{
|
|
||||||
int uc = _inEncoding.convert(_buffer);
|
|
||||||
if (uc == -1)
|
|
||||||
{
|
{
|
||||||
++_errors;
|
++_errors;
|
||||||
return -1;
|
return -1;
|
||||||
@@ -155,6 +140,12 @@ int StreamConverterBuf::writeToDevice(char c)
|
|||||||
_sequenceLength = 0;
|
_sequenceLength = 0;
|
||||||
_pos = 0;
|
_pos = 0;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_sequenceLength = -n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return charToInt(c);
|
return charToInt(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user