473,395 Members | 1,915 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

File.CreateText

Jon
Hello all,

I'm creating a file with the extension mai and the file contents are in
Japanese (シャーのエア抜き). Now the code works and creates the file, but when I open
it in Wordpad, the japanese text has become シャーのエアæ*œã .

Why is this and can anyone help?

Thanks,

Jon
Aug 24 '06 #1
1 3902
Thus wrote Jon,
Hello all,

I'm creating a file with the extension mai and the file contents are
in Japanese (シャーのエア抜き). Now the code works and creates the file, but
when I open it in Wordpad, the japanese text has become
シャーのエアæ*œã .

Why is this and can anyone help?
It seems WordPad only recognizes UTF-8 encoded text when the file includes
a byte order mark (BOM). File.CreateText() creates UTF-8 encoded files without
a BOM.

Therefore, instead of
StreamWriter writer = File.CreateText("file.txt");
use
StreamWriter writer = new StreamWriter("file.txt", false, Encoding.UTF8);
to create your StreamWriter.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Aug 24 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mike | last post by:
I'm trying to create a text file and when i compile my code i keep getting invalid token FileInfo t = new FileInfo("test.txt"); StreamWriter Tex =t.CreateText(); Tex.WriteLine("test file");...
5
by: ad | last post by:
I want to delete some text which begin with <!DOCTYPE and end with > in a file. How can I do it?
1
by: vishal | last post by:
Hello, I have a created a windows service and now I need to create some files from that windows service. The files should be located in the following folder: /root/news/ Unfortunaly when the...
4
by: HNguyen | last post by:
Hi, I have a Web application in ASP.NET. My Application allows the users upload files into the server after checking their user names and passwords. For each transaction, the Web program will...
2
by: Bruce Wiebe | last post by:
hi all im having a problem accessing a text file on my hard disk after ive created it and added some text to it it would appear that the file is still locked. What happens is this i have...
2
by: Microsoft | last post by:
I am trying to use the streamwriter to write to a text file I declare the streamwriter publically at the beginning im filename As String Dim Drive As String Dim oFile As System.IO.File
7
by: David R. | last post by:
Hello all, I would like to generate a Sql-Script-File and a Batch-File to execute the Batch-File over C#-Code and use the SQL-File as an Input-File for the command "osql" in the Batch-File. I...
1
by: Tim Failes | last post by:
This seems a trival question, but I cannot get it to work properly... Essentially my question is, how can I create a text file, and guarantee it is given the current date/time as the Creation Time?...
2
by: TC | last post by:
I need the ability to create a series of individual files via one Streamwriter (one at a time). Currently I have an application that is writing out all of the data to one text file. The user has...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.