Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-12

Errors reading non-English characters

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

David M. Lawrence

I have a computer model that -- under older versions of Lazarus -- compiled and ran fine.

I have been trying to update that model, however, and it does not read non-English characters such as the accented "e" in "Abéché" correctly.

In the older code, the program could read such strings from a text file fine, but when I try to compile an updated version of the program, the updated version reads the site name from a file such as the one below and translates "Abéché" into "Ab?ch?".

Abéché, Chad
13.5 20.9 550
26.8 28.1 31.2 33.3 33.2 32.2 28.7 27.0 28.4 30.0 28.5 25.9
45.0 49.0 50.0 49.0 50.0 48.0 45.0 39.0 45.0 46.0 46.0 43.0
8.0 9.0 11.0 11.0 11.0 15.0 14.0 17.0 15.0 15.0 11.0 10.0
0.0 0.0 0.5 1.0 24.0 26.0 141.0 232.0 67.0 14.0 0.0 0.0
141.0 152.0 189.0 206.0 203.0 175.0 152.0 119.0 138.0 164.0 156.0 132.0
25.0 23.0 21.0 24.0 39.0 47.0 66.0 79.0 66.0 37.0 28.0 29.0
0 0 0 0

Furthermore, the previous version of the model accurately processes batch files of site data like below:

\Africa\Chad\Ndjamena.dat
\Africa\Chad\output\Ndjamena.out
\Africa\Chad\output\Ndjamena.png
0.5
\Africa\Chad\Abéché.dat
\Africa\Chad\output\Abéché.out
\Africa\Chad\output\Abéché.png
0.5

The old version of the program reads batch files just fine. The old code, when recompiled in Lazarus, can process individual data files, such as that for Abéché, OK, but it blows up when trying to process data for Abéché in batch mode. The accented "e" is again corrupted, so the source file cannot be found -- generating a file not found error.

Note that the relevant variables for site and file names are defined as string variables.

So what has changed in Lazarus regarding string processing and what do I need to do to fix the problem? Is there some option I need to set in Lazarus to allow extended character processing? If so, how do I do so?

Dave

------------------------------------------------------ David M. Lawrence | Home: (804) 559-9786 6467 Hanna Drive | Cell: (804) 305-5234 Mechanicsville, VA 23111 | Email: USA | http: http://fuzzo.com ------------------------------------------------------ "All drains lead to the ocean." -- Gill, Finding Nemo "We have met the enemy and he is us." -- Pogo "No trespassing 4/17 of a haiku" -- Richard Brautigan

Reply by email

Mattias Gaertner
to David M. Lawrence
Show quoted text 9 lines
[...] I have been trying to update that model, however, and it does not read non-English characters such as the accented "e" in "Abéché" correctly. In the older code, the program could read such strings from a text file fine, but when I try to compile an updated version of the program, the updated version reads the site name from a file such as the one below and translates "Abéché" into "Ab?ch?". [...]

FPC 3.0.0 introduced string encoding and automatic conversions.

Lazarus and the LCL uses UTF-8 encoded strings. If your file is not UTF-8, but some Windows codepage, that might create such an effect. Probably you need to insert a conversion somewhere.

http://wiki.lazarus.freepascal.org/Better_Unicode_Support_in_Lazarus

Mattias

Reply by email