Skip to content
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

C# Item Template is garbled in multi-byte characters (CJK) #817

Open
shibayan opened this issue Dec 11, 2018 · 4 comments
Open

C# Item Template is garbled in multi-byte characters (CJK) #817

shibayan opened this issue Dec 11, 2018 · 4 comments

Comments

@shibayan
Copy link

@shibayan shibayan commented Dec 11, 2018

Using multibyte characters causes garbled characters.
Visual Studio saves file in Windows default encoding if the file does not have UTF-8 BOM.

@buchizo

This comment has been minimized.

Copy link

@buchizo buchizo commented Dec 16, 2019

If I use string interpolation of ILogger in function app class, log is
garbled when using multi-bytes character.

e.g.

log.LogInformation("ほげほげ: {0}", data);  //no problem
log.LogInformation($"ふがふが: {data}"); //garbled

image

I should ALWAYS change to UTF-8 (with BOM) from default function app code (*.cs) after create project or add function.

@shibayan shibayan changed the title Add UTF-8 BOM for C# Template C# Item Template is garbled in multi-byte characters (CJK) Dec 19, 2019
@shibayan

This comment has been minimized.

Copy link
Author

@shibayan shibayan commented Dec 19, 2019

@soninaren Is this issue recognized? If I can contribute, I will do it happily 😃

@soninaren

This comment has been minimized.

Copy link
Contributor

@soninaren soninaren commented Dec 19, 2019

@shibayan Are you looking at the logs in Application Insights? If yes this is a know issue. Azure/azure-functions-host#4731

@shibayan

This comment has been minimized.

Copy link
Author

@shibayan shibayan commented Dec 20, 2019

@soninaren Thank you for the reply.

Yes, the above image is certainly from Application Insights, but the problem is different.

This problem, Visual Studio saves using the system default encoding (Shift_JIS in Japan) because the Azure Functions project template does not have a UTF-8 BOM.

There is no problem when building on the machine used for development, but there is a problem when combined with CI services such as Azure DevOps.

Repro steps

  1. Create new azure function project with HttpTrigger
  2. Modity OkObjectResult and save
// Replace Hello => こんにちは
(ActionResult)new OkObjectResult($"こんにちは, {name}")
  1. Push to Azure Repos (garbled)

image

  1. Build and Deploy (garbled)

Build with windows agent

image

Build with ubuntu agent

image

Solution

Converting the .cs file to utf-8 + bom encoding will fix it.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.