473,725 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

notepad saves as ANSI, what about c#

Hi,

I produce a text file using my windows application written with c#.
--
System.Text.Enc oding encOutput=null;
encOutput=Syste m.Text.Encoding .UTF8;
StreamWriter sw=new StreamWriter(@" c:\a.txt",false , encOutput);
--
this UTF-8 file will be used to transfer data to another database's
import wizard. Unfortunately db that will import requires the file to be
saved as ANSI in notepad.

Always i have to open the UTF-8 encoded file with notepad and save it as
encoding ANSI in order not to have any problems.

How may i output a text file with an encoding that is compatible with
notepad's ANSI encoding...

Nov 16 '05 #1
2 20370
Hi,

UTF-8 and ANSI are very different beasts. Actually, I suppose the encoding
Notepad refers to as ANSI is the Windows codepage set for the user the
application runs under.
That is, if you create a file in Notepad containing Cyrillic letters, and
your codepage is 1251 (this is Windows codepage for the Russian language),
this file will be actually saved in the 1251 encoding.

So the bottom line is - if your file contains only English letters, numbers
and special characters such as @ or #, use the ASCII encoding. This should
be read by the DB import wizard without any hassle.
If your file will contain some non-English letters, you'd better use Unicode
and tell the DB import wizard to read the file in Unicode
Or, save the file in your current codepage encoding and ensure the same
encoding is used by the DB import wizard.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Ziver MALHASOGLU" <zi*********@ho tmail.com> wrote in message
news:Oi******** *****@TK2MSFTNG P11.phx.gbl...
Hi,

I produce a text file using my windows application written with c#.
--
System.Text.Enc oding encOutput=null;
encOutput=Syste m.Text.Encoding .UTF8;
StreamWriter sw=new StreamWriter(@" c:\a.txt",false , encOutput);
--
this UTF-8 file will be used to transfer data to another database's
import wizard. Unfortunately db that will import requires the file to be
saved as ANSI in notepad.

Always i have to open the UTF-8 encoded file with notepad and save it as encoding ANSI in order not to have any problems.

How may i output a text file with an encoding that is compatible with
notepad's ANSI encoding...


Nov 16 '05 #2
Ziver MALHASOGLU <zi*********@ho tmail.com> wrote:
I produce a text file using my windows application written with c#.
--
System.Text.Enc oding encOutput=null;
encOutput=Syste m.Text.Encoding .UTF8;
StreamWriter sw=new StreamWriter(@" c:\a.txt",false , encOutput);
--
this UTF-8 file will be used to transfer data to another database's
import wizard. Unfortunately db that will import requires the file to be
saved as ANSI in notepad.

Always i have to open the UTF-8 encoded file with notepad and save it as
encoding ANSI in order not to have any problems.

How may i output a text file with an encoding that is compatible with
notepad's ANSI encoding...


Just use Encoding.Defaul t instead of Encoding.UTF8.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3

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

Similar topics

1
3796
by: Trevor Fairchild | last post by:
I need to open an html document in notepad and save it using ANSI encoding. I can do this manually using notepad and File/Save-as, but is there a way to do this from VB. I can open a specific file using the shell command, but I can't find any syntax specifying encode values (the html is in Unicode and I need it in Ansi) Is there by any chance a notepad component, or something?
1
2060
by: Roger | last post by:
I've got some MS-windows (XP only?) related questions; hopefully someone can give me some advise. 1) Is there some way to make notepad to become the front window when it is started from within a tcp-server, using something like os.system("notepad") or os.system("start /w notepad")
3
11262
by: Maya | last post by:
Hey, there! I'm new to vb.net and it seems I wouldn't be able to solve this without help. I have a pipe delimited file that has to be saved in txt format so it could be accepted by my DTS package. If I open and save the file manualy in Wordpad - it works. (not in Notepad otherwise formatting is changed and DTS package won't accept it.)
5
3847
by: RRD | last post by:
On a school network, using notepad or wordpad, running windows xp, the system is not allowing a save as FILE.html. it saves as .txt even when set to 'all files' in notepad and 'text only' in wordpad. Im wondering if there is a system setting that is preventing this. In addition, if anyone knows of kid friendly html authoring sites, i would appreciate some links for teaching html. Thanx in Advance
100
7000
by: Roose | last post by:
Just to make a tangential point here, in case anyone new to C doesn't understand what all these flame wars are about. Shorthand title: "My boss would fire me if I wrote 100% ANSI C code" We are discussing whether this newsgroup should focus on 100% ANSI C or simply topics related to the C language in the real world. There is a C standard which is defined by an international committee. People who write compilers refer to this in...
1
2956
by: jj | last post by:
How do I programatically default the encoding of my "Notepad" into ANSI. My application uses notepad to save some text. Some of the client computers have UTF as the default encoding in their notepad. This adds some characters in my text and creates problems later on managing it. So is there a way to create a text file in notepad with ANSI encoding always? Thanks John
9
3036
by: Sandy | last post by:
can mfc application, send text data to opened notepad file in desktop?(live transfer of data) . can anybody help
3
2486
by: Learning.Net | last post by:
How to read a Unicode data saved as ASCII in notepad file as txt ? I tried using streamReader but it is not showing Unicode data. eg. using (StreamReader sr = new StreamReader(test.txt) { string line; // Read and display lines from the file until the end of // the file is reached. while ((line = sr.ReadLine()) != null) {
6
6181
by: The Bicycling Guitarist | last post by:
Okay my web site grew up and is moving to a non-Windows server, Unix. I am converting my static HTML/CSS files to Drupal content management system. The leading white spaces I use to indent text for easy editing are not collapsed by Drupal, so I installed Cygwin on my Windows machine to simulate a Unix environment and ran a sed command to strip whitespace. When I opened the files in Notepad they were all on one line each. So I tried...
0
8889
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8099
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 project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.