U
ujjwaltrivedi
Hey guys,
Can anyone tell me how to create a text file with Unicode Encoding. In
am using
FileStream Finalfile = new FileStream("finalfile.txt",
FileMode.Append, FileAccess.Write);
###Question:
Now this creates finalfile.txt with ANSI Encoding ...which is a
default. Either tell me how to change the default or how to create a
new file with ecoding already set to unicode.
###Background:
I am already using the work around by which i create a finalfile.txt
manually and then 'save as...' in unicode Encoding. It doesnt work
though.
Basically i need to write English and Japanese characters in the same
file and then use it. If i have a file say finalfile.txt with unicode
encoding and i try to write into it using this code:
FinalStream.WriteLine(EngString + "is written as" + JapaneseString
+"\n");
I am using Encoding for code page 932. And unfortunately i get same
results for any other encoding say 1252 as long as the txt file that i
use as a work-around has unicode Encoding. I dnt understand why it
always takes Japanese characters.
###The Code:
/
****************************************************************************************/
FileStream Engfile = new FileStream("engfile.txt", FileMode.Open,
FileAccess.Read);
FileStream Japanesefile = new FileStream("Japanesefile.txt",
FileMode.Open, FileAccess.Read);
FileStream Finalfile = new FileStream("finalfile.txt",
FileMode.Append, FileAccess.Write);
StreamReader EngStream = new StreamReader(Engfile,Targetencoding);
StreamReader JapaneseStream = new
StreamReader(Japanesefile,Targetencoding);
StreamWriter FinalStream = new StreamWriter(Finalfile,Targetencoding);
string EngString = null;
while ((EngString = EngStream.ReadLine()) != null)
{
string JapaneseString = JapaneseStream.ReadLine();
FinalStream.WriteLine(EngString + "~" + JapaneseString +"\n");
}
/
****************************************************************************************/
TargetEncoding is set as 932 earlier in the application.
Can anyone tell me how to create a text file with Unicode Encoding. In
am using
FileStream Finalfile = new FileStream("finalfile.txt",
FileMode.Append, FileAccess.Write);
###Question:
Now this creates finalfile.txt with ANSI Encoding ...which is a
default. Either tell me how to change the default or how to create a
new file with ecoding already set to unicode.
###Background:
I am already using the work around by which i create a finalfile.txt
manually and then 'save as...' in unicode Encoding. It doesnt work
though.
Basically i need to write English and Japanese characters in the same
file and then use it. If i have a file say finalfile.txt with unicode
encoding and i try to write into it using this code:
FinalStream.WriteLine(EngString + "is written as" + JapaneseString
+"\n");
I am using Encoding for code page 932. And unfortunately i get same
results for any other encoding say 1252 as long as the txt file that i
use as a work-around has unicode Encoding. I dnt understand why it
always takes Japanese characters.
###The Code:
/
****************************************************************************************/
FileStream Engfile = new FileStream("engfile.txt", FileMode.Open,
FileAccess.Read);
FileStream Japanesefile = new FileStream("Japanesefile.txt",
FileMode.Open, FileAccess.Read);
FileStream Finalfile = new FileStream("finalfile.txt",
FileMode.Append, FileAccess.Write);
StreamReader EngStream = new StreamReader(Engfile,Targetencoding);
StreamReader JapaneseStream = new
StreamReader(Japanesefile,Targetencoding);
StreamWriter FinalStream = new StreamWriter(Finalfile,Targetencoding);
string EngString = null;
while ((EngString = EngStream.ReadLine()) != null)
{
string JapaneseString = JapaneseStream.ReadLine();
FinalStream.WriteLine(EngString + "~" + JapaneseString +"\n");
}
/
****************************************************************************************/
TargetEncoding is set as 932 earlier in the application.