June 5th, 2009, 01:45 AM
Working with accented characters in C++ (Linux)
I am working with strings in a program that I am developing in C++ using Geany (Linux/Ubuntu). The main issue is that I have to work with texts written in Spanish, so they contain characters such as "á", "é" or "ñ".
One of the functions that I need most is to find the ASII code of each character in a string. I have found a way to do this:
segmento="á, é, ó are characters that can be found in this sentence";
This is, I convert the string to a char variable and then I get the ASCII codes. The problem is that this does not seem to work correctly with accented characters. For instance, the character "í" seems to be split in two "chars" with two ASCII codes, -61 and -83, when it should be just one code: 237. I think that this is because I get the strings reading UTF-8 files, but this is something that I can not change.
Could someone please help me find a way to get the right ASCII code for the characters of a string, even the accented letters?
Tags for this Thread
Click Here to Expand Forum to Full Width