473,657 Members | 2,579 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

generate text file with other codepage or encoding

Hi,

I've got this code:

Dim fo As File
Dim swriter As StreamWriter

swriter = fo.CreateText(" c:\prueba.txt")
swriter.Write(" this is a test")
swriter.Close()

I'd like to generate this text file choosing the encoding or codepage that I
want. Is there any class I can use to do it?I've tried with 'Encoding'
class, but I don't know how to use it to generate the file with the encoding
I want.

thanks.
Nov 21 '05 #1
3 1709
"fabian" <fa******@naveg alia.com> schrieb:
I'd like to generate this text file choosing the encoding or codepage that
I
want. Is there any class I can use to do it?I've tried with 'Encoding'
class, but I don't know how to use it to generate the file with the
encoding
I want.


Use 'StreamWriter' only and pass the desired encoding to its constructor
(see documentation for overloaded 'StreamWriter' constructors).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
sorry Herfried,

could you give me an example?
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> escribió en el mensaje
news:eJ******** ******@TK2MSFTN GP11.phx.gbl...
"fabian" <fa******@naveg alia.com> schrieb:
I'd like to generate this text file choosing the encoding or codepage
that I
want. Is there any class I can use to do it?I've tried with 'Encoding'
class, but I don't know how to use it to generate the file with the
encoding
I want.


Use 'StreamWriter' only and pass the desired encoding to its constructor
(see documentation for overloaded 'StreamWriter' constructors).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3
Ok, I got it. Thanks a lot!
"fabian" <fa******@naveg alia.com> escribió en el mensaje
news:eQ******** ******@TK2MSFTN GP10.phx.gbl...
sorry Herfried,

could you give me an example?
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> escribió en el
mensaje news:eJ******** ******@TK2MSFTN GP11.phx.gbl...
"fabian" <fa******@naveg alia.com> schrieb:
I'd like to generate this text file choosing the encoding or codepage
that I
want. Is there any class I can use to do it?I've tried with 'Encoding'
class, but I don't know how to use it to generate the file with the
encoding
I want.


Use 'StreamWriter' only and pass the desired encoding to its constructor
(see documentation for overloaded 'StreamWriter' constructors).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Nov 21 '05 #4

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

Similar topics

10
687
by: Christopher H. Laco | last post by:
Long story longer. I need to get web user input into a backend system that a) only grocks single byte encoding, b) expectes the data transer to be 1 bytes = 1 character, and c) uses the HP Roman-6 codepage system wide. As much as it sounds good, UTF/Unicode encoding is not an option, nor is changing the codepage. Tackling the first is easy via Encoding.Default.GetBytes and shoving it over the network. However, Encoding.Default is the...
7
4794
by: Kueishiong Tu | last post by:
I have a text file with wide characters. I use the following C++ code to read them in. However the wide characters are read in properly. What is wrong? String* path = "C:\\Documents and Settings\\kst\\BE.dat"; try { FileStream* fs = new FileStream(path, FileMode::Open); StreamReader* sr = new StreamReader(fs);
13
6106
by: Dan V. | last post by:
How do I create a one line text file with these control codes? e.g.: 144 = 0x90 and 147 = 0x93? I am trying to create a one line text file with these characters all one one row with no spaces. 1. 144 = 0x90 2. 147 = 0x93 3. STX = (^B = 2 = 0x2) 4. NUL = (^@ = 0 = 0x0)
4
7120
by: Ram | last post by:
Dear All, Good Day I am trying to convert a file which is generated on AS400 with codepage 00420 (arabic & English data combination) with no success. But using the same code( and changing 20420 to 708) I am able to convert a file from codepage ASMO 708 to windows based file and it is perfect. The following is the code I tried. i used 20420 codepage which is the nearest match for 00420. but no luck. //Open file for reading and set...
5
15036
by: Lenard Gunda | last post by:
hi! I have the following problem. I need to read data from a TXT file our company receives. I would use StreamReader, and process it line by line using ReadLine, however, the following problem occurs. The file contains characters with ASCII codes above 128. But the file is still text (nothing like UTF7/8 or the like). It also might contain + signs. As a result:
10
3637
by: joelagnel | last post by:
hi friends, i've been having this confusion for about a year, i want to know the exact difference between text and binary files. using the fwrite function in c, i wrote 2 bytes of integers in binary mode. according to me, notepad opens files and each byte of the file read, it converts that byte from ascii to its correct character and displays
4
34149
by: George | last post by:
Hi, I am puzzled by the following and seeking some assistance to help me understand what happened. I have very limited encoding knowledge. Our SAP system writes out a text file which includes German characters. 1. When I use StreamReader(System.String filepath) without specifying an encoding method, the German characters such as Ä are lost when I do a ReadLine()
5
2923
by: al jones | last post by:
I'll find an answer to this yet. I'm trying to read (streamreader and textfieldparser) data from a file which contains umlauted German characters and French with diacriticals. Both streamreader and textfieldparser seem to drop those characters which fall outside ascii range. This is a text file (designers.txt) maintained from within VS 2005, the characters are present in the text file but are dropped in the process of reading them.
4
1996
by: Samuel | last post by:
Hi Currently text file that I create are UTF-8 encoded and I need ANSI encoding how can I do that Thank you, Samuel
0
8392
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
8305
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
8730
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...
1
8503
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,...
0
8605
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 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...
0
7321
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...
0
5632
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();...
0
4151
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...
2
1607
bsmnconsultancy
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...

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.