tags:

views:

528

answers:

1

Let's say I have a TextBox and the user puts some data in it. I then send the data over RPC, with something like this (synchronous version of interface)

public void submitText(String userData) {
  dao.saveText(userData);
}

My questions are:

  • What is the encoding of the userData? This is a trick question, since Strings in java are stored in UTF-16, what I want to know is if my text box sends funny characters like ã or Í or , and if I later feed that chars to a xml document, what should be the xml encoding?
  • Do I need to care about encoding when submitting data this way? Or GWT assures me that the chars within the userData are properly converted from the http request?
A: 

2 issues:

  1. The "Serialization" or "Marshalling" of data built into RPC handles binary conversions such as machine byte order differences.
  2. the "xml document" you refer to should use "UTF-16" encoding if you plan on writing Java Strings as "binary characters" to it.
  3. another approach is to use 8-bit encoding and translate all the 16-bit characters to markup as in non-breaking-space "

 

"

reechard