This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ascii validation  RSS feed

 
rinke hoekstra
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The urlybird 1.1.1 assignment says on the database:

The character encoding is 8 bit US ASCII


I'm doubting about doing validation on this for new or updated records.
Do you people check on this?
 
Romeo Son
Ranch Hand
Posts: 92
Android Eclipse IDE Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I am not doing any validation on the character set.
I just read from the db file using ISO-Latin and writing in it using the same encoding.
 
rinke hoekstra
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, another try, but a bit more specific:

I was using String.getBytes("US-ASCII") to turn my strings into arrays of bytes, ready to be written to the database file.

However, the java API-doc says on this method:
The behavior of this method when this string cannot be encoded in the default charset is unspecified.


In normal language: when I insert an '�' we don't know what happens (in fact, it will be turned into a '?')

Are people using the same String.getBytes methods? What about this? Ignore the problem? or use java.nio.charset.CharsetEncoder?

Or am I too much lost into details?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!