Passing DBCS characters via the Query string is not permitted

Technote (FAQ)
Problem
Passing DBCS characters via the query string is not permitted. However, there is a programmatic solution
Solution
Using the query string to send request parameters along with HTTP request, either manually or programmatically, is a commonly used tool. However, there is a limitation to the values of the characters sent via a query string. According to RFC 2109 and 2068, only ASCII characters from 32 - 127 are permitted. When DBCS characters are sent through the query string, some characters will appear strangely or as question marks and calls made using this information may fail. Therefore it is not permitted to send DCBS (and related) characters along the query string. However, there is a programmatic solution to the situation: Encode the characters before they are sent. The following is an example of how that might be accomplished.

public void handleDBCSCharacters (String header, String value,
HttpServletResponse response){
byte b[];
try {
b = value.getBytes(response.getCharacterEncoding());
} catch (Exception ex) {
b = value.getBytes();
}
char c[] = new char[b.length];
for (int i=0;i<b.length;i++)
c[i]=(char)(((char)b[i])&0xff);
response.setHeader(header,new String(c));
}
Please note that this code is NOT supported by WebSphere or IBM and placed here only as an example of how such encoding might be accomplished and to provide ideas for your own development program..











Document Information

Product categories: Software, Application Servers, Distributed Application & Web Servers, WebSphere Application Server, Double Byte Character Set (DBCS)
Operating system(s): Multi-Platform
Software version: 3.5, 4.0, 5.0, 5.1, 6.0
Software edition: Edition Independent
Reference #: 1079804
IBM Group: Software Group
Modified date: 2003-10-27