azure-functions-templates
azure-functions-templates copied to clipboard
C# Item Template is garbled in multi-byte characters (CJK)
Using multibyte characters causes garbled characters. Visual Studio saves file in Windows default encoding if the file does not have UTF-8 BOM.
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
I should ALWAYS change to UTF-8 (with BOM) from default function app code (*.cs) after create project or add function.
@soninaren Is this issue recognized? If I can contribute, I will do it happily 😃
@shibayan Are you looking at the logs in Application Insights? If yes this is a know issue. https://github.com/Azure/azure-functions-host/issues/4731
@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
- Create new azure function project with HttpTrigger
- Modity
OkObjectResult
and save
// Replace Hello => こんにちは
(ActionResult)new OkObjectResult($"こんにちは, {name}")
- Push to Azure Repos (garbled)
- Build and Deploy (garbled)
Build with windows agent
Build with ubuntu agent
Solution
Converting the .cs
file to utf-8 + bom encoding will fix it.
@soninaren
Hey! How is your progress?
In the meantime, we developers who use multi-byte languages are still manually re-saving in UTF-8.
@shibayan, this a host issue, check this issue https://github.com/Azure/azure-functions-host/issues/4731 for updates. I don't think there is active work for the host work item. It has been added to the triage milestone. Going to close this one out since this is not a templates issue.
@soninaren This is not the AppInsights issue. The root cause is the following shibayan wrote.
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.
Please change Azure Functions template file encoding to UTF-8 BOM from UTF-8 to fix this issue for non ascii users.
Thank you.