Forum > Beginners

Character variables and other languages [SOLVED]

(1/4) > >>

pascal111:
عند مُحاولتي لتعيين قيمة لمُتغيّر لبنة بحرف من لغةٍ أخرى فإنّ ذلكـ عُدّ خطأً من قِبل المُنقّح فهل مُتغيّرات اللبنة لا تقبل إلّا لبنات الآسكي القياسيّة فقط؟

google translate:

"When trying to assign a value to a block "character" variable with a letter from another language, this was considered a mistake by the reviser "debugger". Are the block "character" variables only accept standard ASCII blocks "characters"?"


--- 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";}};} ---var  c:char;  i:integer;  s:string; begin   c:='ل';  i:=ord(c);  str(i,s);   showmessage(s); end;            

Bart:
Char is just a single byte.
So there are only 256 possible values of a Char.
Depending on your system codepage, Char's with a byte value > 127 have differnet meaning.

The text you have on the top of your message cannot be represented with 1-byte chars.
If you paste 1 "block" as you call it into the source editor, it will consist of multiple bytes.

Therefore if you need a variable to hold such a "block", the variable needs to be of the type String or UnicodeString.

Bart

pascal111:

--- Quote from: Bart on May 07, 2021, 06:31:47 pm ---
If you paste 1 "block" as you call it into the source editor, it will consist of multiple bytes.


--- End quote ---

فهمت أي أنّ مُتغيّر اللبنة تعدّى الواحد بايت المُخصّص لمُحتواه.
google translate:

"I understood that the block "character" variable exceeded the 1-byte assigned to its content."


Google called it "block", not me  8)

I'll use "String" or "UnicodeString".

Thaddy:

--- Quote from: Bart on May 07, 2021, 06:31:47 pm ---Char is just a single byte.

--- End quote ---
No, it isn't. <first tme this year grumpy mode  >:D >:D >:D >

Bart, you are smart and you know that.

wp:
Thaddy, run this program and tell us what is displayed on the monitor


--- 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";}};} ---program Project1;begin  WriteLn(SizeOf(char));end.

Navigation

[0] Message Index

[#] Next page

Go to full version