Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

printout "�" turns to u`

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,good day to you,

I have a sample of code here (printing the hole program would not solve this problem I fear),where I have a println statement Sys....tln("depositing �100.00") instead of the British currency pound sign being printed I get a u with an colon above it,could some explain what is happening

I also would like to be able to display the output from the getBalance statements with 2 digits after the point ie;�100.00 and not �100.00023.Could someone advise me to the easiest way to do this.

thankyou.
 
Daniel .J.Hyslop
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I should also state that I am still using sdk 1.4 which does not support the printf(string,double)output stream for formatting numbers
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess your problem with the pound symbol (�) is that you're running the application in a command line box (cmd.exe) in Windows. The problem is that the command line uses a different character set (IBM-PC OEM) than Windows (usually ISO-Latin1 in Western countries). So what you type in a your text editor or IDE does not necessarily show up the same in the console window. This is a problem that shows up quite often when we print message strings in languages other then English.

I can think of three possible solutions:

1. Use an other operating system such as Linux or MacOS X.
2. Have your output go to graphical component (such as a Swing JFrame) instead of the standard output in a console window.
3. Try using the IBM-PC OEM character code for the pound symbol in your string: System.out.println("\u009C");

About printing a numerical quantity with a fixed number of decimal digits, you can use the java.text.DecimalFormat class:

Or, if you�re using Java 5.0, the new printf method comes in handy:

I hope this helps.

...Ariel
 
Would you like to try a free sample? Today we are featuring tiny ads:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic