-
Notifications
You must be signed in to change notification settings - Fork 453
Fix Console Encoding for Proper Display of Non-ASCII Characters #4434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…racters Co-authored-by: liliankasem <[email protected]>
Co-authored-by: liliankasem <[email protected]>
Co-authored-by: liliankasem <[email protected]>
Fix the build errors:
|
var encoding = Program.GetConsoleOutputEncoding(); | ||
|
||
// Assert | ||
encoding.Should().Be(Encoding.UTF8); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this testing even? The code changes included only set Console.OutputEncoding
in Main
, but this test does not call that. If this test is passing, it means the setting of UTF8
in Main
is redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right. The test was flawed because it didn't call Main() to set the encoding. I investigated and found that the default console encoding is System.Text.ConsoleEncoding
(not System.Text.UTF8Encoding
), so our setting in Main() is actually needed. I've removed the problematic helper method and unit test since they weren't meaningful. The E2E tests properly validate the functionality. Commit 7a15472
Co-authored-by: jviau <[email protected]>
... Fixed the StyleCop violations: reordered using directives (SA1208) and removed trailing whitespace (SA1028). Commit 7a15472 Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Issue
Azure Functions Core Tools was not correctly displaying non-ASCII characters in console output. Japanese characters (and other non-Latin scripts) were showing as question marks (
?????
) when logging from a function.Root Cause
The console output encoding was not explicitly set to UTF-8 at application startup, causing the console to use the default encoding of the system, which often doesn't support the full range of Unicode characters.
Solution
Added a single line at the start of the application to configure the console output encoding to UTF-8:
This ensures that all Unicode characters, including Japanese and other non-Latin scripts, are properly displayed in the console when running functions locally.
Screenshot
Changes
Program.cs
Main method to set console encoding to UTF-8System.Text
namespace importFixes #4429.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
azfunc.pkgs.visualstudio.com
dotnet build src/Cli/func/Azure.Functions.Cli.csproj
(dns block)pkgs.dev.azure.com
dotnet build src/Cli/func/Azure.Functions.Cli.csproj
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.