Constructing a string of Unicode characters [SOLVED] lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- carl_caulkett · 2017-06-27 15:00 Lazarus 1.6.4 FPC 3.0.2 macOS 10.12.5 Sierra Hello, I want to construct a string containing several instances of the Unicode equivalent to the old Box Drawing character Ascii code (196). I want to display the string in a TListView which on the Apple Mac defaults to using the Lucida Grande font. I have discovered that the Unicode code for the wide line character that I want is 2500, but the problem is that the command I would normally use, namely, the StringOfChar statement only returns an AnsiString. How can I build a string of Unicode wide line characters? Thanks, Carl ---------------------------------------------------------------------- Thaddy · 2017-06-27 15:40 You do not explain WHAT type of unicode. In UTF8 old code should work. #2500 is UTF16-LE, not UTF8. Try {$mode delphiunicode} ---------------------------------------------------------------------- howardpc · 2017-06-27 16:07 You can do something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormCreate(Sender: TObject);const  Long_Line = '─';var  li: TListItem;  i: Integer;begin  ListView1.Font.Name:='Lucida Bright';  li:=ListView1.Items.Add;  li.Caption:='';  for i:=0 to 19 do begin    li.Caption:=li.Caption+Long_Line;  end;end; ---------------------------------------------------------------------- carl_caulkett · 2017-06-27 19:55 I just get a string of â characters. In my case, I had to use Font.Name:='Lucida Grande'; because the Lucida Bright font is not on my computer. I should also point out that I am using the TListView in virtual mode, the data coming from a TcaUnicodeStringlist class I have written which only deals with UnicodeStrings - no AnsiStrings whatsoever. ---------------------------------------------------------------------- Thaddy · 2017-06-27 20:08 Quote from: carl_caulkett on June 27, 2017, 09:55:50 pmthe data coming from a TcaUnicodeStringlist class I have written which only deals with UnicodeStrings - no AnsiStrings whatsoever. UTF8(bytes vary from 1 to 4) ? UTF16 (full, bytes vary from 2 to 4)? UTF16-LE (partially, Delphi style, bytes fixed at two)?, UTF32 (bytes fixed at four) ? What kind of Unicode? We can't help you when we don't know. Unicode on its own means nothing. If you mean the FPC (not Lazarus) supported UnicodeString type (UTF16-LE) , you also need a unicode16 capable font. This should work, though: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  a: UnicodeChar = #2500; provided the font supports it. And the console supports unicode16. ---------------------------------------------------------------------- carl_caulkett · 2017-06-27 21:25 Of course, when I read that the character I want has a code of 2500, it would help me no end if I took notice of whether that code was in decimal or hex. I tried it with $2500 and the default font and it works perfectly. Nonetheless, I know I'm still quite inexperienced with Unicode (all flavours!) but I can't help feeling that it's a bit of a mess and way more complicated than it needs to be. ---------------------------------------------------------------------- Remy Lebeau · 2017-06-28 23:41 Quote from: carl_caulkett on June 27, 2017, 11:25:14 pmOf course, when I read that the character I want has a code of 2500, it would help me no end if I took notice of whether that code was in decimal or hex. I tried it with $2500 and the default font and it works perfectly. Unicode codepoints (not codes!) are usually expressed in hex with a "U+" prefix.  So, what you are really working with is Unicode codepoint U+2500 DRAWINGS LIGHT HORIZONTAL, which is expressed as $2500 or #9472 in code that works with Unicode characters, or as $C4 or #196 in code that works with Extended ASCII characters.