• 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Can't convert unicode

 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Recently I switched a RCP/swing app from using hypersonic to mysql. The problem is that there are some unicode characters in the data. The data now displays with the unicode characters as unicode in the app. I tried printing out the data from the bean and it comes out the same way on the console. If I cut/paste the string from the console and place another print statement inside the bean I get output with unicode from the field and formatted output from the other print statment. Why???
 
Marshal
Posts: 27371
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If those two lines of code produce different output, that's because they have different inputs. So you should start looking there.

I'm a bit confused because I don't understand a lot of things in your post. First of all, all Java characters are Unicode. They all come from the Unicode character set, which includes ASCII as the first 128 code points. Probably you meant that you have some non-ASCII characters.

And I don't understand what it means to "display as unicode". I don't even have a guess for that, so perhaps you could provide an example.

And this console: is it the Windows console, or the Eclipse console, or a Unix shell? They all have different behaviour.

As for MySQL, when you set it up did you configure the database to use UTF-8 as its default character set or did you use something else? UTF-8 is a better choice if you're going to have international inputs.
 
Pat Peg
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"I'm a bit confused because I don't understand a lot of things in your post. First of all, all Java characters are Unicode. They all come from the Unicode character set, which includes ASCII as the first 128 code points. Probably you meant that you have some non-ASCII characters. "

Yes-I am trying to use non ASCII characters such as degree and some other special math characters.

"And I don't understand what it means to "display as unicode". I don't even have a guess for that, so perhaps you could provide an example."

What I mean is that the first line displays as the actual string with escape character "/u00e5" and the second line displays as the interpreted symbol of what that unicode stands for.

"And this console: is it the Windows console, or the Eclipse console, or a Unix shell? They all have different behaviour."

Eclipse console.

In the application as well, the data is not showing up correctly-in otherwords it has the escape character and not the actual degree symbol. I tried just trying to output the symbol as "°" but the formatting gets lost and so "°F" is rendered int he RCP application as "0F"
 
Paul Clapham
Marshal
Posts: 27371
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pat Peg wrote:What I mean is that the first line displays as the actual string with escape character "/u00e5" and the second line displays as the interpreted symbol of what that unicode stands for.



Seems to me this could only happen if the database actually contains that string. I'm using MySQL, my database actually contains records with the Unicode degree character (which is U+00B0), and my Swing application displays it perfectly well. Can you run the MySQL workbench and see if that's the case? Putting Java Unicode escape sequences into a database would be a rather unusual approach in my opinion.
 
Pat Peg
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like the problem was that when the data was being read in there was an extra "/" being added...why I don't know but I was able to correct it.
 
Sasparilla and fresh horses for all my men! You will see to it, won't you tiny ad?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic