Forum > General
more UTF8 confusing
lazer:
Hi, I'm having UTF8 troubles again. :(
I save my text files, which include accented characters, with featherpad on linux choosing utf8 encoding.
I read them into structures based on the following types.
--- 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 TwordArray = array[0..2] of string[phraselen]; Tcard=record cardwords:TWordArray; phrase:string[phraselen] ;end;
When I display them in a Tpanel.caption , it works fine.
--- 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";}};} --- textPanels[i].panelLabel.caption:= cardstr;
However, I need to copy one char at a time into a grid of TstaticText controls.
--- 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";}};} --- grid[posx][posy+i].Caption:=sisword[i];
This works fine for a..z A..Z but obviously gets confused by multibyte chars.
How can I tell now long each letter is to copy each one correctly to a separte TstaticText ??
TIA.
KodeZwerg:
UTF8Copy may help you.
paweld:
--- 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";}};} ---uses LazUTF8; //... grid[posx][posy+i].Caption := UTF8Copy(sisword, i, 1);
KodeZwerg:
and in addition you may use UTF8Length to be inside legit limit
lazer:
--- 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";}};} --- grid[posx][posy+i].Caption:=UTF8copy(sisword,i,1);
Not seeing any better results.
Navigation
[0] Message Index
[#] Next page