readByte () not return the corresponding character


#1

readByte () not return the corresponding character in cases:

case á returnin int value -31
case Á returnin int value -63
case é returnin int value -23
case É returnin int value -55
case í returnin int value -19
case Í returnin int value -51
case ó returnin int value -13
case Ó returnin int value -45
case ú returnin int value -6
case Ú returnin int value -38
case ÿ returnin int value -1
case Ÿ returnin int value -97

file test.txt

 á
 Á      
 é
 É
 í
 Í
 ó
 Ó
 ú
 Ú
 ÿ
 Ÿ

technique to obtain the real character

String allString;
char caract;
int numValueChar;
caract=MyInputStream->readByte();
            switch(caract)
            {
            case -31://á
                allString=allString+T("á");
                break;
            case -63:
                allString=allString+T("Á");
                break;
            case -23://"é"
                allString=allString+T("é");
                break;
            case -55:
               allString=allString+T("É");
                break;
            case -19://í
               allString=allString+T("í");
                break;
            case -51:
                allString=allString+T("Í");
                break;
            case -13://ó
                allString=allString+T("ó");
                break;
            case -45:
               allString=allString+T("Ó");
                break;
            case -6://ú
               allString=allString+T("ú");
                break;
            case -38:
                allString=allString+T("Ú");
                break;
            case -1:
                allString=allString+T("ÿ");
                break;
            case -97:
               allString=allString+T("Ÿ");
                break;
            default:
               allString=allString+String::charToString(caract);
            }

#2

readByte doesn’t return a character. It returns a byte. They are not the same thing.

The ‘character’ depends entirely on the context of what you’re decoding, and may be one or more bytes. I’d recommend sticking to utf8 rather than whatever 8-bit encoding you’re using here, because it’s universal rather than being country-specific.


#3

thanks jule.


#4

file format that I am manipulating is coded in 8 byte.

thanks for the clarification


#5

#6

very good information!

a question:

My method will be effective for 8-byte encodings in windows and linux.


#7

No.


#8

I can use that technique