[fpc-pascal] ord() of a string index returns wrong value.

Jonas Maebe jonas.maebe at elis.ugent.be
Sat Jan 29 17:13:53 CET 2011


On 29 Jan 2011, at 17:05, Pew (piffle.the.cat) wrote:

> I have a problem where ord() of a character (single string index) returns the wrong value. the character is a 'o' which is a 111 value but the ord of it returns 121 into an integer. What am I doing wrong?

Is that Lazarus code? If so, the string will be utf-8 encoded and you cannot assume that str[i] corresponds to the i'th character of the string. Even if it's not Lazarus code, it could still be utf-8 encoded depending on what the source of the string is and/or the locale settings of the system.


Jonas


More information about the fpc-pascal mailing list