Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4119616
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:06:48+00:00 2026-05-20T23:06:48+00:00

I thought i had this unicode thing down. Then i realize i wasnt saving/parsing

  • 0

I thought i had this unicode thing down. Then i realize i wasnt saving/parsing some text correctly.

Heres the text (sorry, i dont know what it says. A random user wrote it)

Here is simple test code. Essentially i write the BOM for utf-8 unicode and write the source. That didnt work and for sanity reasons i tried saving the file directly (second piece of code). Both got the WRONG text in file and using multiple browsers it showed me incorrect text.

Why and how do i fix it?

Note: With my first code i can see sz holding the same incorrect text using visual studios.

using System;
using System.IO;
using System.Net;
using System.Text;

namespace unicode_stuff
{
    class Program
    {
        static void Main(string[] args)
        {
            var wc = new WebClient();
            var fn = "out.html";
            var sw = new StreamWriter(fn, false, Encoding.UTF8);
            var sz = wc.DownloadString("http://www.pastie.org/pastes/1703099/text");
            sw.WriteLine(sz);
            sw.Close();
        }
    }
}

second

using System;
using System.IO;
using System.Net;

namespace unicode_stuff
{
    class Program
    {
        static void Main(string[] args)
        {
            var wc = new WebClient();
            var fn = "out.html";
            wc.DownloadFile("http://www.pastie.org/pastes/1703099/text", fn);
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:06:49+00:00Added an answer on May 20, 2026 at 11:06 pm

    try setting your encoding to UTF8 before loading:

    wc.Encoding = System.Text.Encoding.UTF8;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I thought I had this mess sorted out in my head but for some
Alright, I thought I had this whole setTimeout thing perfect but I seem to
Hey all. Quick question on Fluent syntax. I had thought I had this down,
I thought I had seen a bug report about this on the jQuery site,
This may seem like a programming 101 question and I had thought I knew
I thought I had this figured out but it turns out I'm just deleting
I thought I had this sorted, but I am still missing something. Very simply,
I am so frustrated. Just when I thought I had this figured out I
So I thought I had fixed the problem posted in this question and I
I thought I had this all figured out, but now that I'm writing a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.