Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blazor displays ¤ instead of $ when using ToString("C")

I'm building a Blazor Web app (wasm). I use ToString("C") to display values as a currency, however the dollar sign is showing up as ¤, for example ¤4.83 instead of $4.83. According to Wikipedia "The currency sign ¤ is a character used to denote an unspecified currency"

This seems like a localization issue, but my browser / Blazor is not detecting that I'm en-US and showing the $ sign. How can I show the correct currency symbol?

I'm currently using .Net 5, but this problem exists on .Net core 3.x as well.

like image 967
Brad Avatar asked Oct 26 '25 05:10

Brad


1 Answers

Add this to startup. I only saw this behaviour when I switched to (WSL 2)

CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
like image 159
Brian Parker Avatar answered Oct 29 '25 02:10

Brian Parker