我正在像这样从远程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
更多推荐
转换" ??????????"阿拉伯语
发布评论