ANSI rather than UTF-8

Hello,

Sorry for my english, french ...

How to work with Arduino 0022 (prog with external editor 'Notepad++' system Windows XP) + Arduino Mega 2560 + graphic Nokia 5110, and use only ANSI table caracters because i don't need UTF-8 and i want to use extra 0x80-0xff caracters to make ligth graphic with easy enter code in 'String' with keybord like 'éàè' in the sketch : print("èéùô"); and get 1 byte code caracter.

The test i make is :

  • sketch is ANSI coding and i get warning :

If this code was created with an older version of Processing,
you may need to use Tools -> Fix Encoding & Reload to update
the sketch to use UTF-8 encoding. If not, you may need to
delete the bad characters to get rid of this warning.

And data in string are hazardous went i upload

  • sketch is UTF-8 coding, i get code Ok but all caracters are 2 bytes and i don't want to make hard an long decode of UTF-8, ANSI will be the only way for me.

Help me ??

Crimson Editor (a free download) lets you specify encoding, including ANSI (UTF8 is an option).

I use that all the time, it is fast and easy to use.

Or do you mean you already have solved that but you get an error while uploading?

It's not the editor, it's the Arduino program ver 0022 who can't compile (see the warning in the quote on first post) sketch with ANSI caracters and make data in string hazardous but not those i write. I have seen the data in the string, for each caracter : i found 3 bytes !!!!

Only when the sketch is in UTF-8 format, the data are in UTF-8 with 2 bytes (ok for UTF-8) for each caracter but i don't need it because i did not want to make or find convert sub-routine, i don't want to lost time just for print on screen. I just want to Arduno's program to put the same code from the string of the sketch (whenever it was ANSI or UTF-8) to the data of the program that y upload in the board.

Is there a parameter in arduino's program to force him to compile ANSI caracters or a compile order to put in the sketch ??

Note : 'Notepad++' can switch ANSI <-> UTF-8.

Thanks...

Write a small utility (eg. in Lua) that takes your ANSI string and converts it into the format:

char x [] = "\xAB\xCD";

Then put that in your sketch.

exactly what i needed for special chars on a LCD! thanx!

I have put up a web page
"Using Non-ASCII chars in Arduino and other micro-processors" (http://www.forward.com.au/pfod/ArduinoProgramming/Languages/index.html)
that covers this topic. It includes a java program to do the conversions to octal
I use octal
char x[] = "Gen\303\256 mangiano una p\303\250sca e pratichino la p\303\251sca.";
rather then hex
char x [] = "\xAB\xCD";
because the C++ compiler gets confused by sequences like \xABc where c is an acsii character you wanted in your string.

drmpf:
because the C++ compiler gets confused by sequences like \xABc where c is an acsii character you wanted in your string.

Oh yes, \xABc must be written as \xAB\x63 and it is not very practical - do anyone know how to end hex number (like \xAB) or how to determine that it is only a two-digit hex number?

K5CZ:

drmpf:
because the C++ compiler gets confused by sequences like \xABc where c is an acsii character you wanted in your string.

Oh yes, \xABc must be written as \xAB\x63 and it is not very practical - do anyone know how to end hex number (like \xAB) or how to determine that it is only a two-digit hex number?

You can always do:

"\xAB" "c"

Thanks.

No hyphen! I have always tried something like that:

"\xAB"+"cde"

What do you mean "no hyphen"? I didn't have one.

Sorry, my english is not good. I had mean the "nothing" between the second and third quotation mark (no operator or so).

Yes, "nothing" is perfectly valid C. Try compiling this:

void setup ()
  {
  Serial.begin (115200);

  Serial.print ("H" "e" "l" "l" "o" "\x0A");
  }  // end of setup

void loop () { }