当前位置: 首页>>代码示例>>C#>>正文


C# CultureInfo.ToLower方法代码示例

本文整理汇总了C#中CultureInfo.ToLower方法的典型用法代码示例。如果您正苦于以下问题:C# CultureInfo.ToLower方法的具体用法?C# CultureInfo.ToLower怎么用?C# CultureInfo.ToLower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CultureInfo的用法示例。


在下文中一共展示了CultureInfo.ToLower方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToUpper

    public static void ToUpper(string localeName)
    {
        TextInfo ti = new CultureInfo(localeName).TextInfo;

        Assert.Equal('A', ti.ToUpper('a'));
        Assert.Equal("ABC", ti.ToUpper("abc"));
        Assert.Equal('A', ti.ToUpper('A'));
        Assert.Equal("ABC", ti.ToUpper("ABC"));

        Assert.Equal("THIS IS A LONGER TEST CASE", ti.ToUpper("this is a longer test case"));
        Assert.Equal("THIS IS A LONGER MIXED CASE TEST CASE", ti.ToUpper("this Is A LONGER mIXEd casE test case"));

        Assert.Equal("THIS \t HAS \t SOME \t TABS", ti.ToUpper("this \t HaS \t somE \t TABS"));

        Assert.Equal('1', ti.ToUpper('1'));
        Assert.Equal("123", ti.ToUpper("123"));

        Assert.Equal("EMBEDDED\0NULL\0BYTE\0", ti.ToUpper("embedded\0NuLL\0Byte\0"));

        // LATIN SMALL LETTER O WITH ACUTE, which has an upper case variant.
        Assert.Equal('\u00D3', ti.ToUpper('\u00F3'));
        Assert.Equal("\u00D3", ti.ToUpper("\u00F3"));

        // SNOWMAN, which does not have an upper case variant.
        Assert.Equal('\u2603', ti.ToUpper('\u2603'));
        Assert.Equal("\u2603", ti.ToUpper("\u2603"));

        // DESERT SMALL LETTER LONG I has an upperc case variant.
        Assert.Equal("\U00010400", ti.ToUpper("\U00010428"));

        // RAINBOW (outside the BMP and does not case)
        Assert.Equal("\U0001F308", ti.ToLower("\U0001F308"));

        // These are cases where we have invalid UTF-16 in a string (mismatched surrogate pairs).  They should be
        // unchanged by casing.
        Assert.Equal("BE CAREFUL, \uD83C\uD83C, THIS ONE IS TRICKY", ti.ToUpper("be careful, \uD83C\uD83C, this one is tricky"));
        Assert.Equal("BE CAREFUL, \uDF08\uD83C, THIS ONE IS TRICKY", ti.ToUpper("be careful, \uDF08\uD83C, this one is tricky"));
        Assert.Equal("BE CAREFUL, \uDF08\uDF08, THIS ONE IS TRICKY", ti.ToUpper("be careful, \uDF08\uDF08, this one is tricky"));

        Assert.Throws<ArgumentNullException>(() => ti.ToUpper(null));
    }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:41,代码来源:TextInfo.cs

示例2: EnUsPosixIsNotATurkishCasingLocale

    public static void EnUsPosixIsNotATurkishCasingLocale()
    {
        // ICU has special tailoring for the en-US-POSIX locale which treats "i" and "I" as different letters
        // instead of two letters with a case difference during collation.  Make sure this doesn't confuse our
        // casing implementation, which uses collation to understand if we need to do turkish casing or not.

        TextInfo ti = new CultureInfo("en-US-POSIX").TextInfo;

        Assert.Equal('I', ti.ToUpper('i'));
        Assert.Equal('i', ti.ToLower('I'));
    }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:11,代码来源:TextInfo.cs

示例3: NoUnicodeSpecialCases

    public static void NoUnicodeSpecialCases(string localeName)
    {
        // Unicode defines some codepoints which expand into multiple codepoints
        // when cased (see SpecialCasing.txt from UNIDATA for some examples).  We have never done
        // these sorts of expansions, since it would cause string lengths to change when cased,
        // which is non-intuative.  In addition, there are some context sensitive mappings which
        // we also don't preform.
        
        TextInfo ti = new CultureInfo(localeName).TextInfo;

        // es-zed does not case to SS when upercased.
        Assert.Equal("\u00DF", ti.ToUpper("\u00DF"));

        // Ligatures do not expand when cased.
        Assert.Equal("\uFB00", ti.ToUpper("\uFB00"));

        // Precomposed character with no uppercase variaint, we don't want to "decompose" this
        // as part of casing.
        Assert.Equal("\u0149", ti.ToUpper("\u0149"));

        // Greek Capital Letter Sigma (does not to case to U+03C2 with "final sigma" rule).
        Assert.Equal("\u03C3", ti.ToLower("\u03A3"));
    }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:23,代码来源:TextInfo.cs

示例4: TurkishICasing

    public static void TurkishICasing(string localeName)
    {
        TextInfo ti = new CultureInfo(localeName).TextInfo;

        Assert.Equal('i', ti.ToLower('\u0130'));
        Assert.Equal("i", ti.ToLower("\u0130"));

        Assert.Equal('\u0130', ti.ToUpper('i'));
        Assert.Equal("\u0130", ti.ToUpper("i"));

        Assert.Equal('\u0131', ti.ToLower('I'));
        Assert.Equal("\u0131", ti.ToLower("I"));

        Assert.Equal('I', ti.ToUpper('\u0131'));
        Assert.Equal("I", ti.ToUpper("\u0131"));
    }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:16,代码来源:TextInfo.cs


注:本文中的CultureInfo.ToLower方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。