Start a new topic

Store text in iso 8859-5 on SD card.

Hi!

Here is what I am trying to do: 

Arduino on some event writes text line to text file on sd card. Then I read this line and send it to text "text" object on display.

There are no problems with text in latin symbols. But I need iso 8859-5 encoding. 

I figured out that if I write text line to sd card in hex (like "\xE2\xD5\xE1\xE2" - word "тест" - test ) and then send this hex line to display it will show symbols correctly(like "тест"), but in this case I won't be able to read this text if I open file on my PC :)  

Question 1: is there any method to write down text line to sd card in native symbols so both human and display could read them.

if no, then Question 2: maybe you know converter tool that converts  iso 8859-5 to hex? I couldn't find one on web search :(



Just for clarity - this is Arduino / PC issue and not Nextion issue

- Nextion does not write to store text on its microSD card


If PC is Russian iso-8859-5 and Nextion HMI is iso-8859-5

 - I am not seeing where the issue is?

Yes. I know. I am speaking not about Nextion's SD card slot.

I figured out what confused me. I use Notepad++ as my code editor. By default it has UTF-8 encoding. I did not pay attention to this when I started to write code. Now I have almost 2000 lines of code with comments in Russian in UTF-8 encoding. And now I figured out that I need to use another encoding to write text to SD card. So when I switch encodings all my comments turn to crap, but sending line shows well. 

Now I have choice to switch encodings every time I edit text which I am sending to SD card or to rewrite all comments with ISO encoding :'(

What a lesson of proper planning..

 or just write a quck and dirty tool, which parse your source and convert all comments from UTF-8 to ISO ... I guess, that's much more speedy ...

Of course. I can just convert text of my program from utf-8 to iso-8859-5 in any online converter and it will solve the problem :P 

There is even no need in parsing

@Ivan

If you need to save data with UTF-8 encoding on your SD card, you can use following conversion from UTF-8 to ISO-8859-5 when you read from SD card and send to Nextion:

[UTF-8] xx yy  ==>  [ISO-8859-5] (xx & 01) * 40 + yy + 20

where xx is D0 or D1.

See also page 9 in the PDF file in this thread:

http://support.iteadstudio.com/support/discussions/topics/11000007764

I needed to save data in ISO encoding. And I would like to share hint about that cause it was not so obvious for me. If you need your text to go SOURCE CODE -> SD -> NEXTION, you cant open text editor, write code in your encoding and simply copy-paste it into Arduino IDE. It won't work. Arduino IDE supports only UTF-8 encoding. In order to make it work you should  do next (I will explain on notepad++ example):

1. Create file in N++, choose desired encoding.

2. Write your code. Save file with .ino extension.

3. Open Arduino IDE. In settings mark checkbox "Use  external editor"

4. Open your sketch in Arduino IDE. Note it would alert you about unknown symbols. Ignore.

5. Upload your sketch to MCU and Nextion will show you correct symbols. 

 

It would be fair for any non latin-symbol language I guess. 


1 person likes this
Login or Signup to post a comment