转换" ??????????"阿拉伯语 [英] Convert "???? ??????" in to arabic language

查看:51
本文介绍了转换" ??????????"阿拉伯语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在像这样从远程sql服务器获取数据

I am getting data from remote sql server like this .

"USER_NAME" ="???? ??????";

"USER_NAME" = "???? ??????";

我必须获得阿拉伯语用户名的值,但我正在获得??????.我在数据库中归档了navchar类型的文本.我正在使用以下代码行:-

I have to get value of username in arabic language but I am getting ??????. I have navchar type of text filed at database. I am using these lines of code:-

NSString *output = [[feed objectForKey:@"USER_NAME"] stringByReplacingPercentEscapesUsingEncoding:NSUnicodeStringEncoding];
                NSLog(@"%@",output);

那我该如何解决呢?

推荐答案

sql服务器显示某些unicode数据可能有两个原因,例如 ????????

There can be two possible reasons for sql server to show some unicode data like ????????

原因1.
当unicode数据插入或更新为unicode数据时用户没有为字符串加上 N 前缀的列.

Reason 1.
when unicode data wan inserted or updated to that column the user didnt prefix the string with N.

原因2.
列本身不是NVARCHAR表示它不允许存储要存储的Unicode字符.

Reason 2.
The Column itself isnt NVARCHAR means it doesnt allow storing unicode characters to be stored.

示例

DECLARE @TABLE TABLE 
(Column1 VARCHAR(100),         --<-- VARCHAR DataType
Column2 NVARCHAR(100),         --<-- NVARCHAR DataType
Column3 NVARCHAR(100)COLLATE  Arabic_CI_AS   --<-- NVARCHAR DataType with specific
)                                               -- arabic collation

INSERT INTO @TABLE VALUES
('هذا هو العربي','هذا هو العربي', 'هذا هو العربي'),    -- Data with out N Prefix
(N'هذا هو العربي',N'هذا هو العربي', N'هذا هو العربي')  -- Data with  N Prefix

SELECT * FROM @TABLE

结果

╔═══════════════╦═══════════════╦═══════════════╗
║    Column1    ║    Column2    ║    Column3    ║
╠═══════════════╬═══════════════╬═══════════════╣
║ ??? ?? ?????? ║ ??? ?? ?????? ║ ??? ?? ?????? ║
║ ??? ?? ?????? ║ هذا هو العربي ║ هذا هو العربي ║
╚═══════════════╩═══════════════╩═══════════════╝

只有数据,其中列"允许存储Unicode字符,而当我使用N前缀时,剩下的数据将只显示???????.

Only data Where Column allows unicode characters to be stored and when I used N prefix will have data stored in the rest are only showing ???????.

如果您只是丢失了数据,则可能无法将其转换回unicode/阿拉伯字符.uch:S

In your case you have simply lost the data you cannot possibly convert it back to unicode / Arabic characters . Ouch :S

这篇关于转换&quot; ??????????&quot;阿拉伯语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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