Click here to Skip to main content
15,888,007 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
hi, I have a winform program in which I have a form to fill in Arabic but I can not get in store Arabic data in a database mysql I see symbols ??????


What I have tried:

namely that the bottom is collating
cp1256_general_ci I find a collation for Arabic.
thank you in advance!
Posted
Updated 5-Nov-16 8:49am

 
Share this answer
 
I had similar problem with Microsoft SQL Server Express Edition.
Instead of playing with collation I have used two simple methods :

C#
string encodeString(string word)
{
    string result = string.Empty;

    char [] letters = (word.Normalize()).ToCharArray();

    foreach (char letter in letters)
    {
        result += ((short)letter).ToString("00000");
        result += " ";
    }
    return (result.Trim()).Normalize();
}

string decodeString(string word)
{
    string result = string.Empty;

    string [] letters = word.Split(' ');

    int code = 0;

    foreach (string letter in letters)
    {
        code = short.Parse(letter);
        result += ((char)code).ToString();
    }
    return result.Normalize();
}


Use dataGridView class type object
for collecting and representing data.

Before writing data from dataGridView fields to Sql data base table fields,
use string encodeString(string word) method to encode data to
simple series of ascii codes.

Before representing data from Sql data base table fields to user,
use string decodeString(string word) method to decode data
from series of ascii codes to normal strings.

It is now possible to save text written in Arabic or any other language
to Sql data base with collation set to Cyrillic_General_CI_AS
or any other collation.



All the best,
Željko Perić
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900