Forum > General
[solved] Case with unicode switch and -FcUTF8
Ocye:
I use case with string labels in my program. Something like:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure Greetings(aLanguage: string);begin case aLanguage of 'English': writeln('Hello World'); 'Deutsch': writeln('Hallo Welt'); 'Français': writeln('Salute Monde'); //error 'Русский': writeln('приве́т мир'); //error end;end;Having the option -FcUTF8 set (RTL with UTF8 support), the compiler complains "Constant and CASE types do not match" for the labels with UTF8 codepoints. Do I really need to type cast or convert?
Lazarus 1.5 rUnknown FPC 3.0.0 i386-win32-win32/win64
JuhaManninen:
http://wiki.freepascal.org/Better_LCL_Unicode_Support
We must also support programs / apps with the default string type (local code page), without the new UTF-8 system.
It apparently causes a swamp of nasty issues but they must listed somewhere and solved as well as possible.
I try to improve the wiki page in near future ...
GetMem:
That case hurts my eyes, but I guess it's just personal preference:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---type TLanguage = (EN, DE, FR, RU); procedure Greetings(const aLanguage: TLanguage);begin case aLanguage of EN: WriteLn('Hello World'); DE: WriteLn('Hallo Welt'); FR: WriteLn('Salute Monde'); RU: WriteLn('приве́т мир'); end;end; //...Greetings(EN);
Roland Chastain:
Hello! This seems to work:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---'Fran'#$C3#$A7'ais': writeln('Salute Monde');
Bart:
What is the encoding of the source-file in question?
The description leads me to believ the souce-file is not UTF8-encoded, and therefore (when specifying FcUTF8) the 'Français' is then a malformed string, and the compiler cannot handle it as a case label?
Bart
Navigation
[0] Message Index
[#] Next page