views:

287

answers:

2

I have a nvarchar(256) field in a SQL 2005 database table that contains several records in Chinese and I'd like to output this characters correctly in VB.NET code.

What I have now doesn't work at all:

Dim MyText As String = "推荐评论: 属于那~种类型的电影"
Dim value As [String] = MyText
Dim tc As Encoding = Encoding.GetEncoding(950)
Dim bytes As Byte() = tc.GetBytes(value)
value = Encoding.Unicode.GetString(bytes)
Console.WriteLine(value + vbCrLf)

MyText string is the Chinese language coming from the db field so no problems there. My problem is how to display "MyText" correctly. What is the right way to do this? I'm using a simple console app to do the test.

Thanks.

A: 

It's not easy to get console applications to correctly display unicode characters. You will find it much easier to write a WinForms application instead.

Mark Byers
Also, in the WinForms App (or WPF for that matter), it will depend on the Font supporting the chinese characters. If it doesn't, all you will see are those lame squares, or funny diamonds with question marks in them
thorkia
A: 

No, I dont have answer but got a similar problem. I output from chinese.asp -, a few line asp code, and then passed theform input to chinese1.asp, but it only give me the hex code rather than the chinese character? Help.

Chinese.asp

Untitled Document

Chinese1.asp

Untitled Document

<% DIM str, s str = Request.Form response.write ("
+" & str & "+
") str = Split(str,"&") For i = 0 To Ubound(str) s = split(str(i), "=") response.Write("
" & s(0) & "=" & s(1)) response.Write("
" & cstr(s(1)) ) Next response.Write("
")

%>

=== best regard from kfl, shenzhen =========

KFLee