Converting unicode code [ANSI format] to unicode glyphs

General TRichView support forum. Please post your questions here
Post Reply
Nostradamus
Posts: 67
Joined: Sat May 13, 2006 1:56 pm
Location: Australia

Converting unicode code [ANSI format] to unicode glyphs

Post by Nostradamus »

Hello Sergey,
I was wondering how to use Delphi [for use in Delphi5 with TNT unicode components and MS Access 2003 database]

to convert 13000 into 𓀀. and vice versa.



This way I can use ANSI format codepoint text to store Egyptian Hieroglyphs inside a MS Access 2003 Database-Table then use the encoder/decoder to
display the Egyptian Hieroglyphs on screen.

Any help is appreciated.

Richard
Nostradamus
Posts: 67
Joined: Sat May 13, 2006 1:56 pm
Location: Australia

Re: Converting unicode code [ANSI format] to unicode glyphs

Post by Nostradamus »

See link below

https://r12a.github.io/uniview/#title

use the section

SHOW BLOCK >>> to select Egyptian Hieroglyphs.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Converting unicode code [ANSI format] to unicode glyphs

Post by Sergey Tkachenko »

If the question is how to display these characters in TRichView...

First, you need a new version of TRichView, where UTF-16 is supported completely.

To insert such codes in TRichView, they need to be converted to UTF16.
TRichView includes a function for this in RVUni unit: RVU_UnicodeCharToUTF16:

Code: Select all

RichViewEdit1.InsertText(RVU_UnicodeCharToUTF16($13000));
RVU_UnicodeCharToUTF16 converts UTF-32 code to up to two WideChars (i.e. to UTF16)
There is also a reverse function, RVU_UTF16ToUnicodeChar, it converts a surrogate pair of WideChars to UTF-32

Also, in TRichViewEdit, you can type 13000 directly in the editor and press Alt+X to convert it to the character.

Also, new version RichViewActions support all Unicode characters in the "Insert Symbol" dialog:
egiptian-hieroglyphs.png
egiptian-hieroglyphs.png (69.17 KiB) Viewed 23833 times
Nostradamus
Posts: 67
Joined: Sat May 13, 2006 1:56 pm
Location: Australia

Re: Converting unicode code [ANSI format] to unicode glyphs

Post by Nostradamus »

Will this code patch work with TDBEdit, TEdit or TText ?

Will it work with Delphi 5 Enterprise , MS Access 2003 Windows XP ?

With regard to
RVU_UnicodeCharToUTF16 converts UTF-32 code to up to two WideChars (i.e. to UTF16)
There is also a reverse function, RVU_UTF16ToUnicodeChar, it converts a surrogate pair of WideChars to UTF-32


Will this work with Delphi 5 on Windows XP?

I have another computer with Windows 7 and Delphi 2010 on that one?
Nostradamus
Posts: 67
Joined: Sat May 13, 2006 1:56 pm
Location: Australia

Re: Converting unicode code [ANSI format] to unicode glyphs

Post by Nostradamus »

I want to store these numbers 13000 13001 13002 in a DBMemo in this format and display them on screen as Script
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Converting unicode code [ANSI format] to unicode glyphs

Post by Sergey Tkachenko »

RVU_UnicodeCharToUTF16 and RVU_UTF16ToUnicodeChar do a very simple math calculation (using information which you can find in Wikipedia), they are platform-independent and Delphi-version-independent.
You can use these functions even in applications that do not use TRichView: copy them to another unit, replacing TRVUnicodeString to UnicodeString or WideString, and TRVUnicodeChar to WideChar.

The result of RVU_UnicodeCharToUTF16 is WideString, you can insert it in TEdit in Delphi5+TNT or Delphi2010.
I believe it should work, at least if you assign a font that has Egyptian glyphs (in TRichView, a font substitution works, so if the font does not have some glyphs, glyphs from another font are used; in standard controls, font substitution may sometime work and sometimes not).
But I suggest you to test.
Post Reply