SPIN compilers and national charsets/encodings
Andrey Demenev
Posts: 377
SPIN compilers are not good in handling strings containing characters that fall outside of Latin-1 charset. PST replaces them with $FF, and BST - with $3F (question mark). So, the question is : what can be done here? I need to have russian strings in my programs
Comments
Use those constants in byte declarations etc where you normally use quoted "strings".
Tedious but workable.
Perhaps create a utility program for your PC that reads in lines of such text in unicode and outputs the required Spin declarations.
have a program that will parse files starting from top file to find all objects, an copy them into a temp directory, converting to single-byte encoding, then launch the actual compiler for the copy of top file in the temp dir.
However I was thinking about this:
In the general case you are tackling internationalization of Spin programs. That is to say that in the original source code I might have a string like "Hello" but I want to compile the program translating "Hello" into some other target language.
So I want to write something like serial.str(string("Hello")) in my code and it comes out as "Terve" for the Finnish version of the program.
Perhaps a smarter scheme could be used which is not much harder to implement. For example in the Qt graphical user environment I might write something like:
Where the "tr" causes the correct translation of the string "Hello" to be used.
You could do the same in Spin. Have your utility parse the source looking for calls to "tr" and replacing them with the translated string characters.
This also need to work for strings defined in DAT like
a_string BYTE tr("Hello")
Translations would be provided in some text files for the parser/converter to use. Then a program could be used in many languages without changing the original source.
Such a feature could be useful in the BST tool for example.
[/FONT]