fpoyavo
asked on
READ unicode text file insert into MS SQL 2005
Hi Experts,
I am really tired :) of trying a number iof things. Here is my problem.
1] I have file which is text / html.
2] This file contains KOI8-R characters and as I understand its Unicode.
3] I am trying to read it using StreamReader sr = new StreamReader(file);
and then
while ((read = sr.ReadLine()) != null)
{ ...........}
4] The application opens it and reads fine but I loose original content menaing when I read and write
line to some output I am not getting what is in input file.
I tried also some decoding / encoding but why should I in the first place :) if the only thing I need is to read this KOI8-R file and write original data into output file or may be insert into SQL 2005 ?
In other words I would get original data from input having KOI-8 (Unicode 650001) into my output file or SQL 2005 table.
I am lost completely.
Please help.
Thank you in advance.
I am really tired :) of trying a number iof things. Here is my problem.
1] I have file which is text / html.
2] This file contains KOI8-R characters and as I understand its Unicode.
3] I am trying to read it using StreamReader sr = new StreamReader(file);
and then
while ((read = sr.ReadLine()) != null)
{ ...........}
4] The application opens it and reads fine but I loose original content menaing when I read and write
line to some output I am not getting what is in input file.
I tried also some decoding / encoding but why should I in the first place :) if the only thing I need is to read this KOI8-R file and write original data into output file or may be insert into SQL 2005 ?
In other words I would get original data from input having KOI-8 (Unicode 650001) into my output file or SQL 2005 table.
I am lost completely.
Please help.
Thank you in advance.
this might be silly, but make sure you have the field property set to nvarchar in your database...
ASKER
I do :) have nvarchar and when I insert and then select from this column I am not getting original content
meaning its somehow decoded or encoded not sure. I can see some unreadable characters and a bunch of commas, digits and special characters but text is not there.
meaning its somehow decoded or encoded not sure. I can see some unreadable characters and a bunch of commas, digits and special characters but text is not there.
hmmm... check regional and language options under control panel... make sure you have all necessary language and or supplemental language packs installed...
ASKER
Hi tuttlepc,
Woudl you be more specific. I do have KOI8-R enabled and I can see it in MS Word.
In terms of language packs I would ask again why would I if I don't conver it. I just need to
read it as RAW data and write it the way it is. :)
Thanks a lot.
Woudl you be more specific. I do have KOI8-R enabled and I can see it in MS Word.
In terms of language packs I would ask again why would I if I don't conver it. I just need to
read it as RAW data and write it the way it is. :)
Thanks a lot.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Well...as I have mentioned it not only SQL. When I am writing input line by line to some output file
I see exactly same problem. It means it happens at the time C3 win app reads it or may be I am not reading correctly ?
Thanks.
I see exactly same problem. It means it happens at the time C3 win app reads it or may be I am not reading correctly ?
Thanks.
ASKER
As far as I know there are few methods of reading input file : Which one will do the job ?
Binary Reader and Writer
Directory, File, DirectoryInfo, and FileInfo
FileStream
MemoryStream
StreamWriter and StreamReader
StringReader and StringWriter
Binary Reader and Writer
Directory, File, DirectoryInfo, and FileInfo
FileStream
MemoryStream
StreamWriter and StreamReader
StringReader and StringWriter
i've always used the StreamWriter and StreamReader
ASKER
Well I did that as well. The question is still opened.
can you post another example of what your expected output would be, and then the result let's say if you were to write it out to a pop up window msg box... or a variable in debug mode what it's showing....
exactly what you've read then exactly what it spits out...
exactly what you've read then exactly what it spits out...
ASKER