Note that there are some explanatory texts on larger screens.

plurals
  1. POInsert unicode text in MySql4 throught ASP.NET
    primarykey
    data
    text
    <p>I'm writing a new website for an institute which has 4000 users that are stored in MySql4 !</p> <p>I'm using mysql-connector/net to connect to MySql database throught asp.net,</p> <p>Everything is OK, EXCEPT updating the info which are in unicode mode !</p> <p>Unfortunately I don't know lot about unicode !</p> <p>Connecting and reading data from MySql database is like this :</p> <pre><code>using MySql.Data.MySqlClient; ... MySqlConnection con; MySqlCommand cmd; string tempstr = "Database=DB-NAME;Data Source=SOURCE;charset=utf8;User Id=USER;Password=PASS"; con = new MySqlConnection(tempstr); con.Open(); cmd = con.CreateCommand(); cmd.CommandText = "select * from list_membership"; cmd.CommandType = CommandType.Text; MySqlDataReader reader = cmd.ExecuteReader(); reader.Read(); </code></pre> <p>Now when I read an address for example I get sth like this: <strong>Ø²ÙØ¬Ø§Ù</strong></p> <p>Fortunately I've solved it using the function blew:</p> <pre><code>public string DecodeFromUtf8(string utf8String) { // copy the string as UTF-8 bytes. byte[] utf8Bytes = new byte[utf8String.Length]; for (int i = 0; i &lt; utf8String.Length; ++i) { //Debug.Assert( 0 &lt;= utf8String[i] &amp;&amp; utf8String[i] &lt;= 255, "the char must be in byte's range"); utf8Bytes[i] = (byte)utf8String[i]; } return Encoding.UTF8.GetString(utf8Bytes, 0, utf8Bytes.Length); } </code></pre> <p>Now I send the junky string to the function and I get correct form like this : زنجان (persian language)</p> <p>The problem is that when I want to update or insert address field for instance, nothing will store in the database except some question marks like this: <strong>???? ?????</strong></p> <p>Anyone know what should I do ?! Is there any reverse form for DecodeFromUtf8 function ?</p> <p>Excuse my bad english, Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
 

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