Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

chinese character  RSS feed

 
Sophia Choi
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried to put a Chinese character into a String variable and let it pass through a bean program in order to translate it into Big5. However, the outcome is ?! .
How can I fix it?
Thanks.
-----

Jsp program:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
</head>
<jsp:useBean id="utilObj" class="cfhc_util.CFHCUtil" scope="session" />
<% String var="早晨"; %>
<% String var2 = utilObj.convert_string_to_chinese("var","Big_5"); %>
<body>
<%@ include file ="header.jsp" %>
Start!!
Var2 = <%=var2%>
<br>
<%=var%>
午安!
</body>
</html>
--------------
Bean program:
public String convert_string_to_chinese(String ps_str) throws IOException
{
funct = "convert_string_to_chinese";
if(ps_str == null || ps_str.length() < 1)
return "";
int len = ps_str.length();
char charArray[] = ps_str.toCharArray();
StringBufferInputStream sb_str = new StringBufferInputStream(ps_str);

try
{
Reader rder = new InputStreamReader(sb_str, "big5");
rder.read(charArray);
rder.close();
String sOut = new String(charArray);
sOut = sOut.substring(0, len/2);
return sOut;
}
catch(IOException ex)
{
display(funct, "Error: ", "Call convert_to_chinese Failed!");
return "";
}
} // End of convert_string_to_chinese()
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!