bool Codec::detect(const string &str) const
{
- Decoder *dec = create_decoder();
+ Decoder *dec = create_decoder(IGNORE_ERRORS);
+
bool result = true;
- try
- {
- for(string::const_iterator i=str.begin(); i!=str.end(); )
- dec->decode_char(str, i);
- }
- catch(const CodecError &)
- {
- result = false;
- }
+ for(string::const_iterator i=str.begin(); (result && i!=str.end()); )
+ result = (dec->decode_char(str, i)!=-1);
delete dec;
switch(err_mode)
{
case TRANSLITERATE:
- return 0xFFFE;
+ return 0xFFFD;
case IGNORE_ERRORS:
return -1;
default: