Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So far the information is:</p> <ol> <li>You are using direct SQL INSERT script to insert into the database.</li> <li>The data appears broken in database.</li> </ol> <p>The problem might lie in two places:</p> <ol> <li><p>In your INSERT statement, did you prefix the insert value with N? </p> <p>INSERT INTO #tmp VALUES (N'全澳甲流确诊病例已破100')</p></li> <li><p>If you prefix the value with N, does the String object hold the correct data?</p> <p>String sql = "INSERT INTO #tmp VALUES (N' " + value + "')"</p></li> </ol> <p>Here I assume <strong>value</strong> is a String object. </p> <p>Does this String object hold the correct Chinese characters? </p> <p>Try print out its value and see.</p> <p><strong>Updated</strong>:</p> <p>Let's assume the INSERT query is constructed as below:</p> <pre><code>String sql = "INSERT INTO #tmp VALUES (N' " + value + "')" </code></pre> <p>I assume <strong>value</strong> holds the Chinese character.</p> <p>Did you assign the Chinese characters into value directly? Like</p> <pre><code>String value = "全澳甲流确诊病例已破100"; </code></pre> <p>The above code shall work. However, if you have done any intermediate processing, it will cause problem. </p> <p>I did a localized TC project before; the previous architect had done several encoding conversions which are necessary in ASP; but they will create problem in .NET:</p> <pre><code> String value = "全澳甲流确诊病例已破100"; Encoding tc = Encoding.GetEncoding("BIG5"); byte[] bytes = tc.GetBytes(value); value = Encoding.Unicode.GetString(bytes); </code></pre> <p>The above conversions are unnecessary. In .NET, simply direct assignment will work:</p> <pre><code> String value = "全澳甲流确诊病例已破100"; </code></pre> <p>That is because String constants and the String object itself are Unicode compliant. </p> <p>The framework library, such as File IO, when reading a file which is not encoded in Unicode, they will convert the foreign encoding to Unicode; in other words, the framework will do this dirty job for you. You do not need to perform manual encoding conversion most of time.</p> <p><strong>Update</strong>: Understood that ASP is used to insert data into an SQL server. </p> <p>I have written a small piece of ASP to insert some Chinese chars into SQL database and it works.</p> <p>I have a database named "trans" and I created a table "temp" inside. <strong>The ASP page is encoded in UTF-8.</strong> </p> <pre><code>&lt;html&gt; &lt;head title="Untitled"&gt; &lt;meta http-equiv="content-type" content="text/html";charset="utf-8"&gt; &lt;/head&gt; &lt;body&gt; &lt;script language="vbscript" runat="server"&gt; If Request.Form("Button1") = "Submit" Then SqlQuery = "INSERT INTO trans..temp VALUES (N'" + Request.Form("Text1") + "')" Set cn = Server.CreateObject("ADODB.Connection") cn.Provider = "sqloledb" cn.Properties("Data Source").Value = ********* cn.Properties("Initial Catalog").Value = "TRANS" cn.Properties("User ID").Value = "sa" cn.Properties("Password").Value = ********** cn.Properties("Persist Security Info").Value = False cn.Open cn.Execute(SqlQuery) cn.Close Set cn = Nothing Response.Write SqlQuery End If &lt;/script&gt; &lt;form name="form1" method="post" action="input.asp"&gt; &lt;input name="Text1" type="text" /&gt; &lt;input name="Button1" value="Submit" type="submit" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The table is defined as belows in my database:</p> <pre><code> create table temp (data NVARCHAR(100)) </code></pre> <p>Submit the ASP page several times and my table contains proper Chinese data:</p> <pre><code>select * from trans..temp data ---------------- test 测试 全澳甲流确诊病例已破100 </code></pre> <p>Hope this can help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload