• Post Reply Bookmark Topic Watch Topic
  • New Topic

help with CharsetEncoder  RSS feed

 
Geoffrey Falk
Ranch Hand
Posts: 171
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to define a custom Charset to map byte values to characters. The legal byte values in my Charset are between 0 and 46. The character values are all uppercase letters, space, numbers, and some punctuation.

I am getting an exception when I try to return the CharsetEncoder:



It fails in the CharsetEncoder constructor with this exception:



After some debugging I found out that something is trying to set a "replacement" with a byte value of 63. This is not a valid value in my character set. Valid values are only from 0 to 46.

What the heck is a "replacement", and why is it trying to set it to 63?

Thanks
Geoffrey
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The concept of "replacement" is explained in the CharsetEncoder API. A byte value of 63 is an ASCII or Unicode '?' - which is what the CharsetEncoder will write, by default, for any value that it doesn't know how to encode. (So if you try to write Chinese, for example, you will probably just see ??? instead unless Chines characters are defined for that encoder.) If you don't want the default replacement of 63 for '?', you should use the CharsetEncoder constructor which allows you to specify a different relacement string. Perhaps a good choice would be whatever numeric value is used for '?' in your custom encoding.
[ June 05, 2005: Message edited by: Jim Yingst ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!