Strange Display in WebListBox

Hi all,

I have a web app which allows user to choose the language of the UI, basically English and Chinese. A table stored in MySql has 2 columns named EDescription (English) and CDescription (Chinese) will be displayed in a WebListBox, depending on the user’s choice of language.

English displays the correct content, but Chinese displays a little bit strange,

“, > 1000’(G)” displayed as “> > 10’0’(G)”

Here is the code:

  Select Case session.DefaultLanguage
  Case app.kLanguageEnglish
    DataList.Cell(RowNo, 2) = rs.Field("EDescription").StringValue
  Case app.kLanguageChinese
    DataList.Cell(RowNo, 2) = rs.Field("CDescription").StringValue
  End Select

Thanks for input.

Strange… suddenly it cures by itself…

This could be an encoding problem. Taking data straight out of a database without setting the encoding to something known can get you all sorts of problems.

The easiest way I’ve found to do this is to write a method like this in a Module somewhere:

[code]Function UTF8(extends aString as String) as String

If aString.Encoding = Encodings.UTF8 then
Return aString
ElseIf aString.Encoding = Nil then
Return DefineEncoding(aString, encodings.UTF8)
Return ConvertEncoding(aString, Encodings.UTF8)
End If

End Function[/code]

Then after you call StringValue, just append .UTF8.

Thanks Greg, I think most of my problems due to Chinese can be solved by your solution. Just curious the string is generated by my web app (not user typed nor copied from other web sites) and stored in a UTF8-coded database, and the data is displayed in the same web app, isn’t that they should be in the same code-set?

There’s an easy way to tell. Assign the value to a string, set a breakpoint right there and check the encoding in the debugger.

If the encoding of the string is nil, the app has no way to know what to do with the text.