Playing with Unicode: A question...
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 348
- Joined: Sun Jul 03, 2011 2:04 am
- Location: Gulf Breeze, Florida
Playing with Unicode: A question...
Hi All,
I have been experimenting with Unicode using LiveCode. Would anyone out there happen to have some sample code for getting the Unicode Number and HTML-Code/UTF-16BE Dec for a specific character? I would also like to learn how to use these numbers/codes to convert to and from Unicode in the LiveCode environment.
For example:
Character: Δ
Unicode Number: U+0394
HTML-Code / UTF-16BE Dec: Δ / 916;
See: https://unicode-table.com/en/0394/
Any code examples, explanations, or sample stacks would be most welcome. So far I've been able to convert Unicode characters to binary, and then back again. It's been fun! (And it's about time I learned this stuff.) I've played around with binaryEncode(), baseConvert(), textDecode(), etc.--and have made some progress--but some examples sure would go a long way.
Thanks!
Keith George Long
a.k.a "Boo"
Gulf Breeze, Florida
I have been experimenting with Unicode using LiveCode. Would anyone out there happen to have some sample code for getting the Unicode Number and HTML-Code/UTF-16BE Dec for a specific character? I would also like to learn how to use these numbers/codes to convert to and from Unicode in the LiveCode environment.
For example:
Character: Δ
Unicode Number: U+0394
HTML-Code / UTF-16BE Dec: Δ / 916;
See: https://unicode-table.com/en/0394/
Any code examples, explanations, or sample stacks would be most welcome. So far I've been able to convert Unicode characters to binary, and then back again. It's been fun! (And it's about time I learned this stuff.) I've played around with binaryEncode(), baseConvert(), textDecode(), etc.--and have made some progress--but some examples sure would go a long way.
Thanks!
Keith George Long
a.k.a "Boo"
Gulf Breeze, Florida
Re: Playing with Unicode: A question...
Hi Keith,
not an expert in Unicode, but you can always use "the templatefield" to get the html for (a) special unicode characte(s).
Example with your delta char:
Hope that helps.
best
Klaus
not an expert in Unicode, but you can always use "the templatefield" to get the html for (a) special unicode characte(s).
Example with your delta char:
Code: Select all
...
set the text of the templatefield to numtocodepoint(0x0394)
put the htmltext of the templatefield
## <p>Δ</p>
## Strip the P tags and you have the html value
reset the templatefield
...
best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Playing with Unicode: A question...
Klaus.
I do not use unicode at all, but wonder why you would use the templateField. The "templateGadgets" are phantom controls with certain properties set, that can be configured as desired and recalled as needed with those properties preloaded front and center.
What are you doing with the templateField that simply setting a custom property would not do better?
Craig
I do not use unicode at all, but wonder why you would use the templateField. The "templateGadgets" are phantom controls with certain properties set, that can be configured as desired and recalled as needed with those properties preloaded front and center.
What are you doing with the templateField that simply setting a custom property would not do better?
Craig
-
- Livecode Opensource Backer
- Posts: 9387
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Playing with Unicode: A question...
Sorry, haven't a clue re the HTML code.
- Attachments
-
- GETTER.livecode.zip
- Stack.
- (1005 Bytes) Downloaded 69 times
Re: Playing with Unicode: A question...
Hi Craig,
setting a custom property might require some more lines to finally get the html value for that unicode character.
Once I finally found out the benefits of "the templatexxx" I tend to use them more often.
Example:
Getting the height and width of an image on disk we can use the template field, so this does not require to create an
extra image and query the formattedheight and formattedwidth of that.
I recently also found that we can even create a snapshot from "the templateimage" after setting its filename!
Now how cool is THAT?
Best
Klaus
setting a custom property might require some more lines to finally get the html value for that unicode character.
Once I finally found out the benefits of "the templatexxx" I tend to use them more often.
Example:
Getting the height and width of an image on disk we can use the template field, so this does not require to create an
extra image and query the formattedheight and formattedwidth of that.
I recently also found that we can even create a snapshot from "the templateimage" after setting its filename!
Now how cool is THAT?
Best
Klaus
Re: Playing with Unicode: A question...
Addendum:
Only fields have the HTMLTEXT property, custom properties don't.
Only fields have the HTMLTEXT property, custom properties don't.
-
- Livecode Opensource Backer
- Posts: 9387
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Playing with Unicode: A question...
I just stole Klaus's code:
- -
Not sure about that semi-colon.
- -
Not sure about that semi-colon.
- Attachments
-
- GETTER.livecode.zip
- Stack.
- (1.15 KiB) Downloaded 68 times
Re: Playing with Unicode: A question...
Sheeesh...
That is part of the HTML code for that character.
-
- Livecode Opensource Backer
- Posts: 9387
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Playing with Unicode: A question...
Aha: last time I looked at HTML was about 17 years ago.That is part of the HTML code for that character.
Code: Select all
on mouseUp
if fld "ff" is not empty then
put fld "ff" into MAGIC
put codePointToNum(MAGIC) into ACHE
put codePointToNum(MAGIC) into fld "gg"
set the text of the templatefield to numtocodepoint(ACHE)
put the htmltext of the templatefield into HWG
delete char 1 of HWG
delete char 1 of HWG
delete char 1 of HWG
delete the last char of HWG
delete the last char of HWG
delete the last char of HWG
delete the last char of HWG
put HWG into fld "hh"
end if
end mouseUp
Re: Playing with Unicode: A question...
You forgot "very verbose"!
Code: Select all
...
## Maybe also a bit clunky, but much less verbose:
put the htmltext of the templatefield into HWG
replace "<p>" with "" in HWG
replace "</p>" with "" in HWG
put HWG into fld "hh"
...
-
- Livecode Opensource Backer
- Posts: 9387
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Playing with Unicode: A question...
OK, OK: here's my excuse:replace "<p>" with "" in HWG
I have 5 Ukrainian families camping around and about and I am running around contacting everyone
trying to find them flats: they idea of 19 "bodies" sleeping on our living room floor makes me feel
very funny indeed.
Oh, and there is the other thing: someone, somewhere quite enjoys teasing a German guitar player.
Re: Playing with Unicode: A question...
Glad he/she doesn't do this with a german BASS player!
-
- Livecode Opensource Backer
- Posts: 9387
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Playing with Unicode: A question...
Your fiddle is another man's bagpipes.
-
- Livecode Opensource Backer
- Posts: 9387
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Playing with Unicode: A question...
I wonder why the OP needs the HTML code for these characters when, as far as I know, all they need to
do us use a WOFF or WOFF2 font.
http://www.techcybers.com/blog/ttf-otf- ... nt-format/
do us use a WOFF or WOFF2 font.
http://www.techcybers.com/blog/ttf-otf- ... nt-format/
-
- Livecode Opensource Backer
- Posts: 9387
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Playing with Unicode: A question...
Thinking about things . . .
How does the new HTML5 "thingy" in LiveCode 10 cope with fonts?
I would assume that it relies on fonts embedded in the source stack?
And are those OTF, TTF, WOFF or WOFF2?
-
How does the new HTML5 "thingy" in LiveCode 10 cope with fonts?
I would assume that it relies on fonts embedded in the source stack?
And are those OTF, TTF, WOFF or WOFF2?
-