Uredi

Deli z drugimi prek


UnicodeCategory Enum

Definition

Defines the Unicode category of a character.

public enum class UnicodeCategory
public enum UnicodeCategory
[System.Serializable]
public enum UnicodeCategory
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum UnicodeCategory
type UnicodeCategory = 
[<System.Serializable>]
type UnicodeCategory = 
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type UnicodeCategory = 
Public Enum UnicodeCategory
Inheritance
UnicodeCategory
Attributes

Fields

Name Value Description
UppercaseLetter 0

Uppercase letter. Signified by the Unicode designation "Lu" (letter, uppercase). The value is 0.

LowercaseLetter 1

Lowercase letter. Signified by the Unicode designation "Ll" (letter, lowercase). The value is 1.

TitlecaseLetter 2

Titlecase letter. Signified by the Unicode designation "Lt" (letter, titlecase). The value is 2.

ModifierLetter 3

Modifier letter character, which is free-standing spacing character that indicates modifications of a preceding letter. Signified by the Unicode designation "Lm" (letter, modifier). The value is 3.

OtherLetter 4

Letter that is not an uppercase letter, a lowercase letter, a titlecase letter, or a modifier letter. Signified by the Unicode designation "Lo" (letter, other). The value is 4.

NonSpacingMark 5

Nonspacing character that indicates modifications of a base character. Signified by the Unicode designation "Mn" (mark, nonspacing). The value is 5.

SpacingCombiningMark 6

Spacing character that indicates modifications of a base character and affects the width of the glyph for that base character. Signified by the Unicode designation "Mc" (mark, spacing combining). The value is 6.

EnclosingMark 7

Enclosing mark character, which is a nonspacing combining character that surrounds all previous characters up to and including a base character. Signified by the Unicode designation "Me" (mark, enclosing). The value is 7.

DecimalDigitNumber 8

Decimal digit character, that is, a character representing an integer in the range 0 through 9. Signified by the Unicode designation "Nd" (number, decimal digit). The value is 8.

LetterNumber 9

Number represented by a letter, instead of a decimal digit, for example, the Roman numeral for five, which is "V". The indicator is signified by the Unicode designation "Nl" (number, letter). The value is 9.

OtherNumber 10

Number that is neither a decimal digit nor a letter number, for example, the fraction 1/2. The indicator is signified by the Unicode designation "No" (number, other). The value is 10.

SpaceSeparator 11

Space character, which has no glyph but is not a control or format character. Signified by the Unicode designation "Zs" (separator, space). The value is 11.

LineSeparator 12

Character that is used to separate lines of text. Signified by the Unicode designation "Zl" (separator, line). The value is 12.

ParagraphSeparator 13

Character used to separate paragraphs. Signified by the Unicode designation "Zp" (separator, paragraph). The value is 13.

Control 14

Control code character, with a Unicode value of U+007F or in the range U+0000 through U+001F or U+0080 through U+009F. Signified by the Unicode designation "Cc" (other, control). The value is 14.

Format 15

Format character that affects the layout of text or the operation of text processes, but is not normally rendered. Signified by the Unicode designation "Cf" (other, format). The value is 15.

Surrogate 16

High surrogate or a low surrogate character. Surrogate code values are in the range U+D800 through U+DFFF. Signified by the Unicode designation "Cs" (other, surrogate). The value is 16.

PrivateUse 17

Private-use character, with a Unicode value in the range U+E000 through U+F8FF. Signified by the Unicode designation "Co" (other, private use). The value is 17.

ConnectorPunctuation 18

Connector punctuation character that connects two characters. Signified by the Unicode designation "Pc" (punctuation, connector). The value is 18.

DashPunctuation 19

Dash or hyphen character. Signified by the Unicode designation "Pd" (punctuation, dash). The value is 19.

OpenPunctuation 20

Opening character of one of the paired punctuation marks, such as parentheses, square brackets, and braces. Signified by the Unicode designation "Ps" (punctuation, open). The value is 20.

ClosePunctuation 21

Closing character of one of the paired punctuation marks, such as parentheses, square brackets, and braces. Signified by the Unicode designation "Pe" (punctuation, close). The value is 21.

InitialQuotePunctuation 22

Opening or initial quotation mark character. Signified by the Unicode designation "Pi" (punctuation, initial quote). The value is 22.

FinalQuotePunctuation 23

Closing or final quotation mark character. Signified by the Unicode designation "Pf" (punctuation, final quote). The value is 23.

OtherPunctuation 24

Punctuation character that is not a connector, a dash, open punctuation, close punctuation, an initial quote, or a final quote. Signified by the Unicode designation "Po" (punctuation, other). The value is 24.

MathSymbol 25

Mathematical symbol character, such as "+" or "= ". Signified by the Unicode designation "Sm" (symbol, math). The value is 25.

CurrencySymbol 26

Currency symbol character. Signified by the Unicode designation "Sc" (symbol, currency). The value is 26.

ModifierSymbol 27

Modifier symbol character, which indicates modifications of surrounding characters. For example, the fraction slash indicates that the number to the left is the numerator and the number to the right is the denominator. The indicator is signified by the Unicode designation "Sk" (symbol, modifier). The value is 27.

OtherSymbol 28

Symbol character that is not a mathematical symbol, a currency symbol or a modifier symbol. Signified by the Unicode designation "So" (symbol, other). The value is 28.

OtherNotAssigned 29

Character that is not assigned to any Unicode category. Signified by the Unicode designation "Cn" (other, not assigned). The value is 29.

Examples

The following example displays the characters and their corresponding code points for characters in the UppercaseLetter category. You can modify the example to display the letters in any other category by replacing UppercaseLetter with the category of interest to you in the assignment to the category variable. Note that the output for some categories can be extensive.

using System;
using System.Globalization;

public class Example
{
   public static void Main()
   {
      int ctr = 0;
      UnicodeCategory category = UnicodeCategory.UppercaseLetter;

      for (ushort codePoint = 0; codePoint < ushort.MaxValue; codePoint++) {
         Char ch = (char)codePoint;

         if (CharUnicodeInfo.GetUnicodeCategory(ch) == category) {
            if (ctr % 5 == 0)
               Console.WriteLine();
            Console.Write("{0} (U+{1:X4})     ", ch, codePoint);
            ctr++;
         }
      }
      Console.WriteLine();
      Console.WriteLine("\n{0} characters are in the {1:G} category",
                        ctr, category);
   }
}
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim ctr As Integer = 0
      Dim category As UnicodeCategory = UnicodeCategory.UppercaseLetter
      
      For codePoint As UShort = 0 To UShort.MaxValue - 1
         Dim ch As Char = Convert.ToChar(codePoint)

         If CharUnicodeInfo.GetUnicodeCategory(ch) = category Then
            If ctr Mod 5 = 0 Then Console.WriteLine()
            Console.Write("{0} (U+{1:X4})     ", ch, codePoint)
            ctr += 1
         End If 
      Next
      Console.WriteLine()
      Console.WriteLine()
      Console.WriteLine("{0} characters are in the {1:G} category", 
                        ctr, category)   
   End Sub
End Module

Remarks

A member of the UnicodeCategory enumeration is returned by the Char.GetUnicodeCategory and CharUnicodeInfo.GetUnicodeCategory methods. The UnicodeCategory enumeration is also used to support Char methods, such as IsUpper(Char). Such methods determine whether a specified character is a member of a particular Unicode general category. A Unicode general category defines the broad classification of a character, that is, designation as a type of letter, decimal digit, separator, mathematical symbol, punctuation, and so on.

This enumeration is based on The Unicode Standard, version 5.0. For more information, see the "UCD File Format" and "General Category Values" subtopics at the Unicode Character Database.

The Unicode Standard defines the following:

A surrogate pair is a coded character representation for a single abstract character that consists of a sequence of two code units, where the first unit of the pair is a high surrogate and the second is a low surrogate. A high surrogate is a Unicode code point in the range U+D800 through U+DBFF and a low surrogate is a Unicode code point in the range U+DC00 through U+DFFF.

A combining character sequence is a combination of a base character and one or more combining characters. A surrogate pair represents a base character or a combining character. A combining character is either spacing or nonspacing. A spacing combining character takes up a spacing position by itself when rendered, while a nonspacing combining character does not. Diacritics are an example of nonspacing combining characters.

A modifier letter is a free-standing spacing character that, like a combining character, indicates modifications of a preceding letter.

An enclosing mark is a nonspacing combining character that surrounds all previous characters up to and including a base character.

A format character is a character that is not normally rendered but that affects the layout of text or the operation of text processes.

The Unicode Standard defines several variations to some punctuation marks. For example, a hyphen can be one of several code values that represent a hyphen, such as U+002D (hyphen-minus) or U+00AD (soft hyphen) or U+2010 (hyphen) or U+2011 (nonbreaking hyphen). The same is true for dashes, space characters, and quotation marks.

The Unicode Standard also assigns codes to representations of decimal digits that are specific to a given script or language, for example, U+0030 (digit zero) and U+0660 (Arabic-Indic digit zero).

Applies to

See also