Accidental Reverse order String display

R

Roedy Green

I discovered the oddest thing. drawString in AWT and JTextArea in
Swing were painting one line in my font sample in reverse order.
It is stored in normal order, and displays on the console in normal
order.

It looks like this:

public static final String currencySymbols =
"$ " // $
+ "\u00a2 " // cent sign
+ "\u00a3 " // pound sterling sign
+ "\u00a4 " // general currency sign
+ "\u00a5 " // Yen
+ "\u060b " // Afghani sign
+ "\u0e3f " // Thai Baht
+ "\u17db " // Kmer Riel
+ "\u20a1 " // Costa Rica Colon
+ "\u20a2 " // Brazil Cruzeiro
+ "\u20a3 " // French Franc
+ "\u20a4 " // Lira
+ "\u20a5 " // mil
+ "\u20a6 " // Nigera Naira
+ "\u20a7 " // Spain Peseta
+ "\u20a8 " // India Rupee
+ "\u20a9 " // Korea Won
+ "\u20aa " // Israel new shequel
+ "\u20ab " // VietName Dong
+ "\u20ac " // Euro
+ "\u20ad " // Laos Kip
+ "\u20ae " // Mongolia Tugrik
+ "\u20af " // Greek Drachma
+ "\u20b1 " // peso
+ "\u20b2 " // Paraguay Gurani
+ "\u20b4 " // Urkraine Hryvnia
+ "\u20b5 " // Ghana cedi
+ "\ufdfc"; // rial

I gather the presence of some exotic character in there is sufficient
to trigger that behaviour.

--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
A

Andrew Thompson

I discovered the oddest thing. drawString in AWT and JTextArea in
Swing were painting one line in my font sample in reverse order.
It is stored in normal order, and displays on the console in normal
order. ....
I gather the presence of some exotic character in there is sufficient
to trigger that behaviour.

Yes, it is like the effect you see displayed by this code..
<http://www.physci.org/launcher.jsp?class=/codes/eg/JArabicInUnicode>

Because it is Arabic, the letters appear in reverse order.
 
R

Raymond DeCampo

Roedy said:
I discovered the oddest thing. drawString in AWT and JTextArea in
Swing were painting one line in my font sample in reverse order.
It is stored in normal order, and displays on the console in normal
order.

It looks like this:

public static final String currencySymbols =
"$ " // $
+ "\u00a2 " // cent sign
+ "\u00a3 " // pound sterling sign
+ "\u00a4 " // general currency sign
+ "\u00a5 " // Yen
+ "\u060b " // Afghani sign
+ "\u0e3f " // Thai Baht
+ "\u17db " // Kmer Riel
+ "\u20a1 " // Costa Rica Colon
+ "\u20a2 " // Brazil Cruzeiro
+ "\u20a3 " // French Franc
+ "\u20a4 " // Lira
+ "\u20a5 " // mil
+ "\u20a6 " // Nigera Naira
+ "\u20a7 " // Spain Peseta
+ "\u20a8 " // India Rupee
+ "\u20a9 " // Korea Won
+ "\u20aa " // Israel new shequel
+ "\u20ab " // VietName Dong
+ "\u20ac " // Euro
+ "\u20ad " // Laos Kip
+ "\u20ae " // Mongolia Tugrik
+ "\u20af " // Greek Drachma
+ "\u20b1 " // peso
+ "\u20b2 " // Paraguay Gurani
+ "\u20b4 " // Urkraine Hryvnia
+ "\u20b5 " // Ghana cedi
+ "\ufdfc"; // rial

I gather the presence of some exotic character in there is sufficient
to trigger that behaviour.

How about a SSCCE?

Ray
 
R

Roedy Green

I discovered the oddest thing. drawString in AWT and JTextArea in
Swing were painting one line in my font sample in reverse order.
It is stored in normal order, and displays on the console in normal
order.

It turns out a single character is the culprit
// + "\u060b " // Afghani sign

Remove that from the list and it behaves normally.

--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
R

Roedy Green

Yes, it is like the effect you see displayed by this code..
<http://www.physci.org/launcher.jsp?class=/codes/eg/JArabicInUnicode>

That is so neat. I never would have guessed it was so straight
forward.

--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
J

jan V

That is so neat. I never would have guessed it was so straight forward.

If you're impressed by that little snippet of internationalization support,
you'll be mightily impressed by the stuff contained in O'Reilly's excellent
book called "Java Internationalization".. it's pretty amazing what Java can
do on that front (and which virtually nobody uses...!).
 
J

Jeff Schwab

Andrew said:


Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.

Please contact the server administrator, (e-mail address removed) and
inform them of the time the error occurred, and anything you might have
done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use
an ErrorDocument to handle the request.
Apache/1.3.33 Server at www.physci.org Port 80
 
A

Andrew Thompson

That is so neat. I never would have guessed it was so straight
forward.

It is neat, but there was a niggling doubt in my mind
that I thought I'd better check. Ahhh, yep. Here it is..
<http://groups.google.com/group/comp.lang.java.programmer/msg/0086cdc2bfbc82b7>

You do a lot of 1.1 applets, right? The reversing effect
of the printing will *not* work in the MSVM.

(Though you might accommodate the MSVM by specifically
checking for it and ..reversing the text. ..uggh. )
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

AWT font != Swing Font 0

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top