在mysql数据库中存储阿拉伯语文本 [英] Storing arabic text in mysql database

查看:99
本文介绍了在mysql数据库中存储阿拉伯语文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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!

推荐答案

使用 UTF8 代替,阅读:在MySQL数据库中保存阿拉伯语数据 - Stack Overflow [ ^ ]
Use UTF8 instead, read this : Save Data in Arabic in MySQL database - Stack Overflow[^]


我遇到了与Microsoft SQL Server Express Edition类似的问题。

我没有使用整理,而是使用了两种简单的方法:



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

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();
}





使用dataGridView类类型对象

来收集和表示数据。



在将数据从dataGridView字段写入Sql数据库表字段之前,

使用 string encodeString(string word)将数据编码为

简单系列ascii代码的方法。



在将数据从Sql数据库表字段表示给用户之前,

使用字符串decodeString(字符串字)解码数据的方法

从一系列ascii代码到普通字符串。



现在可以将用阿拉伯语或任何其他语言写的文本保存到Sql数据库中,并将整理设置为 Cyrillic_General_CI_AS

或任何其他整理。







一切顺利,
$ b $bŽeljkoPerić



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ć


这篇关于在mysql数据库中存储阿拉伯语文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆