Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

use StreamWriter to output lines with accented or special characters?

$
0
0

hi guys.

I have a program where the users do many many many things, but one of those things is enter text. Specifically, name of an artist/band, song name, album, etc.

I need to allow the user to encode the output text file to ANSI or UTF-8.

I have StreamWriter doing that with the following code

StreamWriter swSongsDta;

if (mMainForm.EncodeUTF8)
{
    swSongsDta = new StreamWriter(fsongsdta, false, System.Text.Encoding.UTF8);
}
else
{
    swSongsDta = new StreamWriter(fsongsdta, false, System.Text.Encoding.Default);
}

this creates the file in the correct format, according to NotePad++. However, the accented character from the input string (from a textbox) shows up wrong in both ANSI or UTF8 formatting.

for my testing i'm using Michael Bublé. the é fails to show correctly in either encoding.

is this because the file is encoding in UTF8/ANSI but not the text being written to it? if so, how can I convert/encode the string prior to passing it to StreamWriter?

thanks!


EDIT: while i'm at it, the little i know of Visual C# has been self-taught, googling and using this forum over the past ~5 weeks. HOW do I create a submenu visually during design? not at runtime? I can't seem to drag the one menu to be under the other, instead they just alternate placement in the same drop down. i want to take a few and make them children of a few major items, but this seems to escape me. all the samples I found online were for doing it at runtime, not how the simple thing is done in the editor.

Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>