C#:无法从MYSQL数据库将数据打印为Unicode字符 [英] C# : Unable to print data as unicode characters from MYSQL database

查看:121
本文介绍了C#:无法从MYSQL数据库将数据打印为Unicode字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一个Windows应用程序,该应用程序允许用户保存数据并查看泰米尔字体的数据.我安装了"Bamini"字体(泰米尔字体),并将文本框和datagridview设置为Bamini字体.我能够保存和检索泰米尔语中的数据.

Hi I have developed a windows application which allows user to save data and see data in tamil font. I installed 'Bamini' font (Tamil font), and set textboxs and datagridview to Bamini font. I am able to save and retrieve data in tamil.

问题是我输入的泰米尔数据已编码并保存在数据库中 例如:如果我在文本框中输入இந்தியா"并保存,则在mysql db中将其另存为,e; j_ah"(我已将列字符集设置为utf8). 因此,当我获取数据并尝试打印时,它正在打印,e; j_ah"而不是இந்தியா".

The problem is the tamil data i enter is encoded and saved in database for example: if i enter 'இந்தியா' in textbox and save, it is saved as ",e;j_ah" in mysql db (i have set the column character set as utf8). Due to this when i get the data and try to print it, it is printing ",e;j_ah" instead of 'இந்தியா'.

有人可以让我知道我在这里做错了吗!!

Can anyone let me know what i am doing wrong here?!

我用来插入字符串的代码:

textBox1的值为'இந்தியா'(因为文本框字体设置为'Bamini'泰米尔字体)

textBox1 values is 'இந்தியா' (since textbox font is set to 'Bamini' tamil font)

     string insertdata = "INSERT INTO tamil (country) VALUES (@cnt)";
     MySqlCommand cmd = new MySqlCommand(insertdata,connection);
     connection.Open();
     cmd.Parameters.AddWithValue("@cnt",textBox1.Text);
     cmd.ExecuteNonQuery();
     connection.Close();

数据库受到以下影响:

      tablename: Tamil
      Sno   Country
      1     ,e;j_ah

表结构:

          CREATE TABLE `tamil` (                              
            `sno` int(11) auto_increment NOT NULL,                        
            `Description` varchar(50) NOT NULL,                          
            `Country` varchar(50) character set utf8 NOT NULL,                         
            KEY `id_sno` (`sno)                             
          ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ; 

推荐答案

经过一连串的尝试,我终于找到了另一种解决方案,可以在打印机中打印泰米尔字符. 注意:硬件技术支持告知我,许多热敏打印机都不接受通过原始打印机帮助程序类发送的泰米尔字符.

After a long list of trials, i finally found an alternative solution to print tamil characters in my printer. Note: Hardware Tech support informed me that many thermal printers wont accept tamil characters that are sent through raw printer helper class.

因此,我设计了一份苛刻的报告并尝试打印,这立即获得了成功. (我的打印机是3英寸热敏打印机)

So i designed a crsytal report and tried printing, which was immediate success. (My printer is 3inch thermal printer)

这篇关于C#:无法从MYSQL数据库将数据打印为Unicode字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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