On 14 March 2013 21:14, Mohammad Al Houssami (Alumni) <mha53@mail.aub.edu> wrote:
I am trying to build a tokenizer according to the spec below http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.htm...
Let me take the Data State as an example it says Consume the next input character:
U+0026 AMPERSAND (&) Switch to the character reference in data state.
So I want to consume the next character of the HTML file and compare it to U+0026. The encoding is probably utf-8 since itâs the most common. The problem is that some characters cannot be written to us the asUnicode function.
For example you have these cases which are not trivial: U+0009 CHARACTER TABULATION (tab) U+000A LINE FEED (LF) U+000C FORM FEED (FF) U+0020 SPACE
In java you simply do if (c == '\u009'). How does this go in Smalltalk?
in smalltalk you do it: c = Character tab ifTrue: [... ] ifFalse: [... ] for many other 'funky' characters you can use convertor method, which converts integer to character: 1234 asCharacter asUnicode => 1234
-----Original Message----- From: pharo-users-bounces@lists.gforge.inria.fr [mailto:pharo-users-bounces@lists.gforge.inria.fr] On Behalf Of Igor Stasenko Sent: Thursday, March 14, 2013 8:05 PM To: A friendly place where any question about pharo is welcome Subject: Re: [Pharo-users] Unicode in Smalltalk
On 14 March 2013 20:58, Mohammad Al Houssami (Alumni) <mha53@mail.aub.edu> wrote:
Hello again.
Does anyone know how can we reflect Unicode characters in Smalltalk?
what you mean reflect?
I want to read characters and compare them with a Unicode representation. Like U+0026 for & or U+003C for < and so on..
Piece of cake. $& asUnicode hex '16r26' $< asUnicode hex '16r3C'
In Pharo, Character(s) are inherently stored in unicode.
So your main question would be, where you wanna read from (file/network), and what encoding the source uses (utf-8, ucs-16 ucs-32 etc)...
Thanks
Mohammad
-- Best regards, Igor Stasenko.
----- No virus found in this message. Checked by AVG - www.avg.com Version: 2013.0.2904 / Virus Database: 2641/6173 - Release Date: 03/14/13
-- Best regards, Igor Stasenko.