Unicode Library decimal digit and numeric functions














































Unicode Library decimal digit and numeric functions



Python Unicode data:

The 'unicodedata' library in python is helpful in defining the properties for all the Unicode characters available in the Unicode database. This library accesses the Unicode Character Database (UCD) for defining the characters.

 

The next three functions defined here are:

1. unicodedata.decimal(chr)

2. unicodedata.digit(chr)

3. unicodedata.numeric(chr)

 

Before describing the above mentioned functions, lets be clear on the fact that what is decimal, digit and numeric values for a character.

 

Each character in the Unicode character set have a Numeric Type property. This property can have  4 possible values and those are: 

Numeric-Type=Decimal

Numeric-Type=Digit

Numeric-Type=Numeric

Numeric-Type=None

 

The first type, i.e. Numeric-Type=Decimal property is limited to those numeric characters those which are used in decimal-radix numbers and for which a full set of digits has been encoded in a continuous range of ascending numeric values with the digit zero as the first code point in the range. Thus we can say that characters with this property are basically decimal digits. These exclude some characters such as the Chinese, Japanese and Korean ideographic digits, because they are not encoded in continuous range. Subscripts and superscripts are also excluded.

 

The second type i.e. Numeric-Type=Digit property does state that the character should be containing the digit values but it does not necessarily impose all the strict rules set in the Numeric-Type=Decimal property.

 

The third type i.e. Numeric-Type=Numeric basically represents all those characters that represent some or the other numbers that does not fit into the category of either the Numeric-Type-Decimal and nor in the Numeric-Type=Digit.

 

The fourth type i.e. Numeric-Type=None basically includes all those characters that does not represent numbers in any form.

 

The below defined functions are helpful in extracting the decimal, digit or numeric values for the mentioned characters if their Numeric-Type=Decimal, Digit or Numeric respectively.

If the Numeric_Type=None property character is fed into these functions then the function returns the ValueError.

 

unicodedata.decimal(chr):

This is a function defined in the unicodedata library that returns the decimal values assigned to the character 'chr' as integer type. 

 


 

If no such value is defined, then is available the default value is printed otherwise a ValueError is displayed.

 


 

The value returned is of type 'int'.

 



unicodedata.digit(chr):

This is a function defined in the unicodedata library of python which returns the digit value of the character 'chr' entered as the argument in the function as integer . 

 


 

 

If no such value is defined, a default value is returned otherwise ValueError is raised.

 


 

The value returned is of type 'int'.

 


 

unicodedata.numeric(chr):

This is a function defined in the unicodedata library of python which returns the numeric value of the character 'chr' provided as an argument to the function as float. 

 


 

 

If no such value is defined, then the default value id returned otherwise ValueError is raised.

 


 

The value returned is of type 'float'.

 


 


More Articles of Arkaja Sharan:

Name Views Likes
Python codecs Library Error Handling schemes module functions 77 0
Python codecs Library Error Handler register_error and lookup_error functions 71 0
Python codecs Library Error Handlers 76 0
Python codecs Library open and EncodedFile functions 66 0
Python codecs Library iterencode and iterdecode functions 85 0
Python codecs Library register and unregister functions 64 0
Python codecs Library getreader and getwriter functions 79 0
Python codecs Library getincrementalencoder and getincrementaldecoder 64 0
Python codecs Library getencoder and getdecoder functions 70 0
Python Introduction to codecs Library 99 0
Python fcntl Library flock and lockf functions 78 0
Python fcntl Library fcntl and ioctl functions 89 0
Python Resource Library resource usage functions 90 0
Python Resource Library resource usage symbolic constants 73 0
Python Resource Library Resource Limit Functions 86 0
Python resource library resource limit symbolic constants 80 0
Python Introduction to Resource Library 69 0
Python stringprep Library in_table_d1 and in_table_d2 functions 76 0
Python stringprep Library in_table_c8 and in_table_c9 functions 81 0
Python stringprep Library in_table_c5 in_table_c6 and in_table_c7 functions 68 0
Python stringprep Library in_table_c3 and in_table_c4 functions 75 0
Python stringprep library in_table_c21 in_table_c22 and in_table_c21_c22 77 0
Python stringprep library functions in_table_c11 in_table_c12 and in_table_c11_c12 77 0
Python Introduction to stringprep Library 79 0
Python unicodedata library is_normalized unidata_version and ucd_3_2_0 75 0
Python Unicodedata Library functions normalize and decomposition 130 0
Python Unicodedata Library functions east_asian_width and mirrored 82 1
Python Unicodedata Library category bidirectional and combining functions 114 0
Introduction to Unicodedata library lookup and name functions 79 0
Unicode Library decimal digit and numeric functions 81 0
Introduction to Unicode Data library 0 0

Comments