C
C#13mo ago
Carl Murray

❔ € symbol prints to console in Rider, but not Visual Studio

Hey all, Sorry if this is a stupid question, but I'm using Rider IDE on Ubuntu and working on a college assignment. The lecturer uses VS and will be grading our work based on correct output showing. My program involves printing the euro symbol € to console. It works fine by default in Rider by just using Console.WriteLine("€") However, I tested it in VS on Windows, and the € symbol loads as '?' instead. I have fixed this by adding Console.OutputEncoding = System.Text.Encoding.Unicode; , and it now works in VS on Windows But my questions are: 1. How do I know that this method will work all the time, for all operating systems and computers etc.? 2. Is there any standard practice/guideline I can implement in my C# programs to ensure the output prints as expected regardless of the system being used? 3. Why does it work fine in Rider without the above line of code, but not in VS? What is Rider doing behind the scenes that VS isn't doing that makes it require the above line? 4. Should I be including the above line in all of my programs?
5 Replies
x0rld 👻 🎃
x0rld 👻 🎃13mo ago
it's cause visual studio use the cmd ton run vs rider use powershell no ?
Angius
Angius13mo ago
It will not work all the time, for all operating systems and computers Or, rather, it will output the character, but it won't necessarily show Some terminals might not support Unicode Some might not have a font that supports the given character And so on
ZacharyPatten
ZacharyPatten13mo ago
Console.OutputEncoding = Encoding.UTF8; o sorry i see you already added it... cross platform compatability will always have caveats. what you did is the best practice. if the user has chosen to customize their console with a font that does not support UTF characters... that is on the user... not your app
Carl Murray
Carl MurrayOP13mo ago
thanks all for the comments!
Accord
Accord13mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server