Solved

VB.Net: UTF-8 Output Should Be ASCII

Posted on 2014-07-21
6
719 Views
Last Modified: 2014-07-21
Good Day Experts!

I have a little VB.Net application that uses the IO.StreamWriter to output data to  .CSV files that we send to the Client.

My feedback from them indicates the files are encoded in UTF-8 and that once converted to ASCII they were able to import.

I have never purposefully sent files encoded in any fashion.  Can you help me understand what I need to do in order to send them ASCII files so they don't have to convert them?

Thanks,
jimbo99999
0
Comment
Question by:Jimbo99999
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 6

Accepted Solution

by:
ksrsrinivasan earned 167 total points
ID: 40209346
You have to specify the encoding when you create the StreamWriter. Refer the constructor overload with encoding here
0
 
LVL 14

Assisted Solution

by:quizwedge
quizwedge earned 167 total points
ID: 40209366
Check out the StreamWriter constructor at http://msdn.microsoft.com/en-us/library/3aadshsx(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1 The second parameter is the encoding. You should be able to use System.Text.ASCIIEncoding.
0
 

Author Comment

by:Jimbo99999
ID: 40209388
Ok...thanks guys I appreciate the help sice I never did this before.

I will try now and report back.

Thanks,
jimbo99999
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:Jimbo99999
ID: 40209409
I took a look at my code and am not sure how to integrate what you have shown me.

Here is what I have:

Public out As IO.StreamWriter
out = My.Computer.FileSystem.OpenTextFileWriter(FileName, False)
out.AutoFlush = True
out.WriteLine(HDRString)

Do I have to revise my style of coding to incorporate your suggestions?

Thanks again,
jimbo99999
0
 
LVL 6

Expert Comment

by:ksrsrinivasan
ID: 40209433
Replace
out = My.Computer.FileSystem.OpenTextFileWriter(FileName, False)

Open in new window

with
out = New StreamWriter(FileName, False, Encoding.ASCII)

Open in new window

0
 
LVL 63

Assisted Solution

by:Fernando Soto
Fernando Soto earned 166 total points
ID: 40209461
Hi jimbo99999;

Change this line :

out = My.Computer.FileSystem.OpenTextFileWriter(FileName, False)

To this :

out = My.Computer.FileSystem.OpenTextFileWriter(FileName, False, System.Text.Encoding.ASCII)

You could use at the end of that line System.Text.Encoding.Default because the default encoding using the third parameter is ASCII
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question