Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
dears

i have a strange bug in using StreamReader.readline in a file contains english / arabic letters

the code is as following :

C#
StreamReader reader = new StreamReader(textFile, System.Text.Encoding.UTF8 )


if i am reading the following :

line1: 8
line2: xxxxxx  --> arabic letters 


the readline() worked so fine

but incase of the following

line1: 2
line2: xxxxxx  --> arabic letters same as the above example


the readline() return ??????? after reading line2

i tried many encoding and i also open the file in the notepad++ , i found the arabic letters are so normal

so What is the problem here

thanks bye
Posted
Comments
AlphaDeltaTheta 18-May-13 21:43pm    
Is your file saved in utf8??
Sergey Alexandrovich Kryukov 18-May-13 22:08pm    
Not enough information. You can make a shorted possible text file sample with Arabic letters and shorted possible code sample reading it, trying to reproduce the problem. Make sure the file is saved in UTF8 and UTF8 is used in code.

Don't forget that Unicode string could be correct, but you might just not see it. It depends on how you look at it. Say, if you do System.Console.WriteLine(string) (in default settings), it will show correct Unicode as "?????...".
—SA
Andre T.G. 20-May-13 3:05am    
You're getting a ? because there's nothing at the specific unicode code point in utf8... The file simply isn't utf8.

ATG

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