Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1216

How to encode string in utf-8 in C# if I am fetching Environment.Username which is non ascii

$
0
0
using System;namespace GetUsernameExample{    class Program    {        static void Main(string[] args)        {            string username = Environment.UserName; //нпп            Console.WriteLine("Hello, " + username);         }    }}

In this sample code, I want to get username which is non ascii string but I am getting output as "???"

I tried Console.OutputEncoding = Encoding.UTF8; and enabling "Beta: Use Unicode UTF-8 for worldwide language support"; then I get the correct non ascii output but I don't want to do the above (as I want to try out in application code not from console app, how can I encode in utf-8 and get the non ascii output).


Viewing all articles
Browse latest Browse all 1216

Trending Articles



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