List Info

Thread: New to greasemonkey - unicode character problems




New to greasemonkey - unicode character problems
user name
2006-10-11 09:06:37
Hi,

I'm new to greasemonkey, but I have something important that
I'm trying 
to accomplish with it.

My script involves using an associative array to directly
map one 
language/phrase to another language/phrase.  The source
language is in 
Japanese and I have been attempting to use rot180 ( 
ht
tp://www.tobez.org/download/greasemonkey/#rot180 )
and/or the 
dumbquotes example from the dive-into manual 
(http://diveintogreasemonkey.org/casestudy/dumbquotes.ht
ml ) as a model.

Anyway, what I found was that I get the following error:

     Error: syntax error
     Source File:
     Line: 2
    Source Code: 2

This seems to be directly due to saving unicode text cut and
pasted into 
the associative array from the web site in question.

As soon as I save the file using ansi text, this error goes
away, but 
the characters in the associative array do not render
correctly.

I have also tried saving the chracters/phrase to a unicode
text file 
while attempting to use a hex editor to determine the hex
values of the 
two byte character encodings, which I then plug into the
ansi 
greasemonkey script ("x<hex codes for
chracters/phrase>" : "translation 
of chracters/phrase", ).  The result is that the
chracters/phrase is not 
translated.

Any pointers would be greately appreciated....


_______________________________________________
Greasemonkey mailing list
Greasemonkeymozdev.org
http:
//mozdev.org/mailman/listinfo/greasemonkey
New to greasemonkey - unicode character problems
user name
2006-10-11 13:00:17
On 10/11/06, gm-ml <gm-mlsunny-net.ne.jp> wrote:
> I have also tried saving the chracters/phrase to a
unicode text file
> while attempting to use a hex editor to determine the
hex values of the
> two byte character encodings, which I then plug into
the ansi
> greasemonkey script ("x<hex codes for
chracters/phrase>" : "translation
> of chracters/phrase", ).  The result is that the
chracters/phrase is not
> translated.

Instead of using 'xHHxHH' to escape characters, try
'uHHHH', which
refers to a Unicode code point, rather than just bytes. Hope
that
helps.
_______________________________________________
Greasemonkey mailing list
Greasemonkeymozdev.org
http:
//mozdev.org/mailman/listinfo/greasemonkey
New to greasemonkey - unicode character problems
user name
2006-10-11 16:14:56
On 10/11/06, gm-ml <gm-mlsunny-net.ne.jp> wrote:
> Hi,
>
> I'm new to greasemonkey, but I have something important
that I'm trying
> to accomplish with it.
>
<snip>
> This seems to be directly due to saving unicode text
cut and pasted into
> the associative array from the web site in question.
>
> As soon as I save the file using ansi text, this error
goes away, but
> the characters in the associative array do not render
correctly.
>
> I have also tried saving the chracters/phrase to a
unicode text file
> while attempting to use a hex editor to determine the
hex values of the
> two byte character encodings, which I then plug into
the ansi
> greasemonkey script ("x<hex codes for
chracters/phrase>" : "translation
> of chracters/phrase", ).  The result is that the
chracters/phrase is not
> translated.
>
<snip>

With a quick test, it looks like you can just use UTF8... 
At least,
Firefox trunk, GM 0.6.4

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1)
Gecko/20061009 Minefield/3.0a1

-- 
Mook
mook dot moz plus stuff at gmail
_______________________________________________
Greasemonkey mailing list
Greasemonkeymozdev.org
http:
//mozdev.org/mailman/listinfo/greasemonkey
New to greasemonkey - unicode character problems
user name
2006-10-16 15:31:50
> With a quick test, it looks like you can just use
UTF8...  At least,
> Firefox trunk, GM 0.6.4

Correct. The uXXXX tip certainly has the very neat added
advantage of
not requiring additional explanations we are unable to give
about how
to set up the unknown-to-us-editing-environment to produce
UTF8 rather
than some other random encoding of choice. (Windows is
natively fond
of UTF16, for instance.)

-- 
 / Johan Sundström, http://ecmanaut.blogspo
t.com/
_______________________________________________
Greasemonkey mailing list
Greasemonkeymozdev.org
http:
//mozdev.org/mailman/listinfo/greasemonkey
[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )