Bill Page wrote:
>
> On 6 April 2014 18:54, Waldek Hebisch <[email protected]> wrote:
> >
> > I have now added 'uentries' to String. With it 'utf2cork'
> > should look like:
> >
> > utf2cork(s : String) : String ==
> > concat [cork(c) for c in uentries s]
> >
> > 'cork' should now take SingleInteger argument, and the table
> > should consist of pairs (String, SingleInteger).
> >
>
> Thanks for this. I have a couple of questions.
>
> Why did you choose List SingleInteger as the return type of uentries?
> it seems a little none standard. I see that ucodeToString has Integer
> -> String and
> ord$Character returns Integer and char has Integer -> Character.
One reason is to make it potentially more efficient. You
can cheaply and safely convert SingleInteger to Integer
(in fact, in many cases compiler will do this automatically
for you), but safely going in the opposite direction requires
a test (if you are sure that number are in reange you can
use 'qconvert'). Also, the result is codepoints, so
SingleInteger helps to remaid users that they are not
arbitrary integers. Overall, reasons are not strong...
I see that compiler forced you to write things like '120537::SI'.
I admit that I forgot about this, we probably should modify
compiler to accept integer literals as SingleInteger.
> I wrote:
>
> cork(x) ==
> for i in Cork repeat
> if ord(i.unicode.1)::SingleInteger = x then return i.corkcode
> char(x::Integer)::String
>
> but maybe that should be
>
> cork(x) ==
> for i in Cork repeat
> if ord(i.unicode.1)::SingleInteger = x then return i.corkcode
> ucodeToString(x::Integer)
>
> I am not sure.
IIUC the translation table is supposed to contain all nontrivial
unicode characters appearing in the output. So the last
line of 'cork' should be executed only for ASCII characters.
If that is the case, then both variants are equivalent.
The difference is if there are untranslated unicode characters.
'char' in such case may send complete garbage. 'ucodeToString'
will send valid UTF-8. What Texmacs will do with UTF-8 is
another story, but in the second variant we will send
something sensible, so it looks better.
--
Waldek Hebisch
[email protected]
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.