How to fix strange conversion from String.ToUpper() in C#
I'm trying to show something like "contáctenos" in uppercase, but when I use the string.toUpper() method I have the strange result "CONTáCTENOS" instead of "CONTÁCTENOS".
The page "culture" is set correctly to "es-ES" and the "uiculture" too. How can I obtain the correct开发者_如何学Go result if it's possible, without using regex or replace.
Thanks in advance...
use:
.ToUpper(new CultureInfo("es-ES", false));
reference: http://msdn.microsoft.com/en-us/library/24kc78ka.aspx
The string.ToUpper()
function uses CultureInfo.CurrentCulture
, not the page's specific culture or the CurrentUICulture
. You can pass the page's CultureInfo
into the ToUpper
function and this should properly transform your string.
精彩评论