Hi,
I have following code:
Encoding mode; // Encoding.Defaul t or Encoding.UTF8
FileStream sb = new FileStream(full PathAndFileName , FileMode.Create );
StreamWriter sw = new StreamWriter(sb , mode);
sw.Write(textCo ntent);
sw.Close();
My question is under what situation, the saved files are different by
calling Encoding.Defaul t and Encoding.UTF8.
--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy 5 3654
Hardy Wang <ha********@mar ketrend.com> wrote: I have following code: Encoding mode; // Encoding.Defaul t or Encoding.UTF8 FileStream sb = new FileStream(full PathAndFileName , FileMode.Create ); StreamWriter sw = new StreamWriter(sb , mode); sw.Write(textCo ntent); sw.Close();
My question is under what situation, the saved files are different by calling Encoding.Defaul t and Encoding.UTF8.
They'll almost certainly be different for any string containing non-
ASCII characters. They're likely to be the same for any string
containing solely ASCII characters.
See http://www.pobox.com/~skeet/csharp/unicode.html for more
information.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Thanks,
Anybody knows are there any characters in French and Spanish greater than
128 ASCII code?
--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com... Hardy Wang <ha********@mar ketrend.com> wrote: I have following code: Encoding mode; // Encoding.Defaul t or Encoding.UTF8 FileStream sb = new FileStream(full PathAndFileName , FileMode.Create ); StreamWriter sw = new StreamWriter(sb , mode); sw.Write(textCo ntent); sw.Close();
My question is under what situation, the saved files are different by calling Encoding.Defaul t and Encoding.UTF8.
They'll almost certainly be different for any string containing non- ASCII characters. They're likely to be the same for any string containing solely ASCII characters.
See http://www.pobox.com/~skeet/csharp/unicode.html for more information.
-- Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
Hardy Wang <ha********@mar ketrend.com> wrote: Anybody knows are there any characters in French and Spanish greater than 128 ASCII code?
There are no such thing as ASCII values above 127. What did you mean,
exactly?
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Let me make it clear, I am just wandering if there are any characters in
French and Spanish non ASCII character.
What I would like to know is, if there are such characters, by using
Encoding.Defaul t (US English or Canada English as Win2000's locale) to save
to a text file, will these characters be lost?
Thanks!
--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com... Hardy Wang <ha********@mar ketrend.com> wrote: Anybody knows are there any characters in French and Spanish greater
than 128 ASCII code?
There are no such thing as ASCII values above 127. What did you mean, exactly?
-- Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
Hardy Wang <ha********@mar ketrend.com> wrote: Let me make it clear, I am just wandering if there are any characters in French and Spanish non ASCII character.
Certainly - any accented characters, to start with.
What I would like to know is, if there are such characters, by using Encoding.Defaul t (US English or Canada English as Win2000's locale) to save to a text file, will these characters be lost?
Possibly. However, there are various characters in Encoding.Defaul t
which *aren't* in ASCII, and which won't be lost.
I'd strongly recommend using UTF-8 if you have the opportunity,
however.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Achim Domma |
last post by:
Hi,
I read a webpage via urllib2. The result of the 'read' call is of type
'str'. This string can be written to disc via
file('out.html','w').write(html). Then I write the string into a Memofield
in an Access database, using adodbapi. If I read the text back I get a
unicode string, which can not written to disc via file(...) due to encoding
problems. How do I have to decode the unicode string to get my original data
back?
|
by: Majed |
last post by:
Hi , all
I'm trying to write unicode to a file for another app (not developed with
vs2003) to read it. I used StreamWriter with unicode encoding.but I was
surprised that the streamwriter adds FFFE to the start of the file,which
stopes the other app from reading it!!
any idea how to stope it frome doing that,do I have to use another class
#####writer that supports unicode?
help me Please!
Thanks
|
by: Hardy Wang |
last post by:
Hi,
I have following code:
Encoding mode; // Encoding.Default or Encoding.UTF8
FileStream sb = new FileStream(fullPathAndFileName, FileMode.Create);
StreamWriter sw = new StreamWriter(sb, mode);
sw.Write(textContent);
sw.Close();
My question is under what situation, the saved files are different by
calling Encoding.Default and Encoding.UTF8.
|
by: Jim Lawton |
last post by:
Hi,
..net c# httphandler straight html form at browser.
GBP pound sign problem (I know I know - I *can* decode it, but I've got to
understand what and why I should be doing stuff)
I am uploading text data from a form. This data is either directly input into a
textarea, or is a file stream originating from a .txt file, (or other basic text
file (like off Mac or Unix - of course I don't necessarily know at present it's
|
by: MrNobody |
last post by:
I am having alot of difficulty with text files in .NET when they have special
characters like Ã, ó, ç etc...
When i read a text file with them and then write it back out it ignores all
of those characters completely.
I tried all the encoding types and it seems only Encoding.Default does it
right... but it sounds dangerous... can I rely on Encoding.Default behaving
like this for all other machines?
| |
by: Thomas W |
last post by:
I'm getting really annoyed with python in regards to
unicode/ascii-encoding problems.
The string below is the encoding of the norwegian word "fødselsdag".
I stored the string as "fødselsdag" but somewhere in my code it got
translated into the mess above and I cannot get the original string
back. It cannot be printed in the console or written a plain text-file.
I've tried to convert it using
|
by: MaxMax |
last post by:
Is it possible to tell to the WebClient to use an "automatic" encoding when
doing DownloadString? The encoding of the connection is written in the
header, so the WebClient should be able to sense it, but I wasn't able to
find the option. I can only use a fixed Encoding (UTF8 for example) and hope
the site use it.
--- bye
|
by: deloford |
last post by:
Hi
This is going to be a question for anyone who is an expert in C# Text Encoding.
My situation is this: I have a Sybase database which is firing back ISO-8559 encoded strings. I am unable to get the db to translate to UTF-8 for non technical reasons.
So I have a string coming back with the character œ (ISO value 156). this character appears in .NET as a box character because 156 is not a valid Unicode character value.
I have been...
|
by: arunairs |
last post by:
Hi,
After writing the £ (pound sterling) symbol to a file using
StreamWriter using the default encoding UTF8, when I retrieve it the
file symbol £ gets changed. But when I use Encoding.Default in the
StreamWriter, I am able to retrieve the symbol without any issue.
Can you tell me why this is so? Microsoft recommend using UTF8 for
encoding, but it does not seem to work in this case.
thanks,
|
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,...
|
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...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |