home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Programming / ICU / src / icu / source / common / unicode.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-08-16  |  5.2 KB  |  247 lines

  1. /*
  2. *******************************************************************************
  3. *                                                                             *
  4. * COPYRIGHT:                                                                  *
  5. *   (C) Copyright Taligent, Inc.,  1996, 1997                                 *
  6. *   (C) Copyright International Business Machines Corporation,  1996- 1998    *
  7. *   Licensed Material - Program-Property of IBM - All Rights Reserved.        *
  8. *   US Government Users Restricted Rights - Use, duplication, or disclosure   *
  9. *   restricted by GSA ADP Schedule Contract with IBM Corp.                    *
  10. *                                                                             *
  11. *******************************************************************************
  12. */
  13. //  Copyright (C) 1994-1995 Taligent, Inc. All rights reserved.
  14. //
  15. //  FILE NAME : unicode.cpp
  16. //
  17. //  CREATED
  18. //      Wednesday, December 11, 1996
  19. //  
  20. //  CHANGES
  21. //      Wednesday, February 4,  1998
  22. //      Changed logic in toUpperCase and toLowerCase in order
  23. //      to avoid 0xFFFF to be returned when receiving 
  24. //      confusing Unichar  to lowercase or to uppercase
  25. //      (e.g. Letterlike symbols)
  26. //
  27. //  CHANGES BY
  28. //  Bertramd A. DAMIBA
  29. //
  30. //  CREATED BY
  31. //      Helena Shih
  32. //
  33. //  CHANGES
  34. //      Thursday, April 15, 1999
  35. //      Modified the definitions of all the functions
  36. //      C++ Wrappers for Unicode
  37. //  CHANGES BY
  38. //      Madhu Katragadda
  39. //   5/20/99     Madhu        Added the function u_getVersion()
  40. //  07/09/99     stephen        Added definition for {MIN,MAX}_VALUE
  41. //********************************************************************************************
  42.  
  43. #include "unicode.h"
  44.  
  45. #include "uchar.h"
  46.  
  47.  
  48. const UChar Unicode::MIN_VALUE = 0x0000;
  49. const UChar Unicode::MAX_VALUE = 0xFFFF;
  50.  
  51.  
  52. Unicode::Unicode() 
  53. {
  54. }
  55.  
  56. Unicode::Unicode(const  Unicode&    other) 
  57. {
  58. }
  59.  
  60. Unicode::~Unicode() 
  61. {
  62. }
  63.  
  64. const Unicode&
  65. Unicode::operator=(const    Unicode&    other)
  66. {
  67.     return *this;
  68. }
  69.  
  70. // Checks if ch is a lower case letter.
  71. bool_t
  72. Unicode::isLowerCase(UChar ch) 
  73. {
  74.     return (u_islower(ch) );
  75. }
  76.  
  77. // Checks if ch is a upper case letter.
  78. bool_t
  79. Unicode::isUpperCase(UChar ch) 
  80. {
  81.     return (u_isupper(ch) );
  82. }
  83.  
  84. // Checks if ch is a title case letter; usually upper case letters.
  85. bool_t
  86. Unicode::isTitleCase(UChar ch) 
  87. {
  88.     return (u_istitle(ch) );
  89. }
  90.  
  91. // Checks if ch is a decimal digit.
  92. bool_t
  93. Unicode::isDigit(UChar ch)
  94. {
  95.     return (u_isdigit(ch) );
  96. }
  97.  
  98. // Checks if ch is a unicode character with assigned character type.
  99. bool_t
  100. Unicode::isDefined(UChar ch) 
  101. {
  102.     return (u_isdefined(ch) );
  103. }
  104.  
  105.  
  106. // Gets the character's linguistic directionality.
  107. Unicode::EDirectionProperty
  108. Unicode::characterDirection( UChar ch )
  109. {   
  110.     
  111.     return ((EDirectionProperty)u_charDirection(ch) );
  112. }
  113.  
  114. // Get the script associated with the character
  115. Unicode::EUnicodeScript
  116. Unicode::getScript(UChar ch)
  117. {
  118.     
  119.  
  120.     return ((EUnicodeScript) u_charScript(ch) );
  121. }
  122.  
  123. // Checks if the Unicode character is a base form character that can take a diacritic.
  124. bool_t
  125. Unicode::isBaseForm(UChar ch)
  126. {
  127.     return (u_isbase(ch) );
  128.  
  129. }
  130.  
  131. // Checks if the Unicode character is a control character.
  132. bool_t
  133. Unicode::isControl(UChar ch)
  134. {
  135.     return( u_iscntrl(ch) );
  136. }
  137.  
  138. // Checks if the Unicode character is printable.
  139. bool_t
  140. Unicode::isPrintable(UChar ch)
  141. {
  142.     return( u_isprint(ch) );
  143. }
  144.  
  145. // Checks if the Unicode character is a letter.
  146. bool_t
  147. Unicode::isLetter(UChar ch) 
  148. {
  149.     return(u_isalpha(ch) );
  150. }
  151.  
  152. // Checks if the Unicode character can start a Java identifier.
  153. bool_t 
  154. Unicode::isJavaIdentifierStart(UChar ch)
  155. {
  156.     return( u_isJavaIDStart(ch) );
  157. }
  158.  
  159. // Checks if the Unicode character can be a Java identifier part other than starting the
  160. // identifier.
  161. bool_t 
  162. Unicode::isJavaIdentifierPart(UChar ch)
  163. {
  164.     return (u_isJavaIDPart(ch) );
  165. }
  166.  
  167. // Checks if the Unicode character can start a Unicode identifier.
  168. bool_t 
  169. Unicode::isUnicodeIdentifierStart(UChar ch)
  170. {
  171.     return(u_isIDStart(ch));
  172. }
  173.  
  174. // Checks if the Unicode character can be a Unicode identifier part other than starting the
  175. // identifier.
  176. bool_t 
  177. Unicode::isUnicodeIdentifierPart(UChar ch)
  178. {
  179.     return (u_isIDPart(ch) );
  180. }
  181.  
  182. // Checks if the Unicode character can be ignorable in a Java or Unicode identifier.
  183. bool_t 
  184. Unicode::isIdentifierIgnorable(UChar ch)
  185. {
  186.     return( u_isIDIgnorable(ch) );
  187. }
  188.  
  189. // Transforms the Unicode character to its lower case equivalent.
  190. UChar         
  191. Unicode::toLowerCase(UChar ch) 
  192. {
  193.     return (u_tolower(ch) );
  194.     
  195. }
  196.     
  197. // Transforms the Unicode character to its upper case equivalent.
  198. UChar 
  199. Unicode::toUpperCase(UChar ch) 
  200. {
  201.     return(u_toupper(ch) );
  202. }
  203.  
  204. // Transforms the Unicode character to its title case equivalent.
  205. UChar 
  206. Unicode::toTitleCase(UChar ch)
  207. {
  208.     return(u_totitle(ch) );
  209. }
  210.  
  211. // Checks if the Unicode character is a space character.
  212. bool_t
  213. Unicode::isSpaceChar(UChar ch) 
  214. {
  215.     return(u_isspace(ch) );
  216. }
  217.  
  218. // Gets if the Unicode character's character property.
  219. int8_t
  220. Unicode::getType(UChar ch)
  221. {
  222.     return(u_charType(ch) );
  223. }
  224.  
  225.  
  226.  
  227. // Gets table cell width of the Unicode character.
  228. uint16_t
  229. Unicode::getCellWidth(UChar ch)
  230. {
  231.     return (u_charCellWidth(ch) );
  232. }
  233.  
  234. int32_t            
  235. Unicode::digitValue(UChar ch)
  236. {
  237.     return (u_charDigitValue(ch) );
  238. }
  239.  
  240. const char*
  241. Unicode::getVersion()
  242. {
  243.     return (u_getVersion() );
  244. }
  245.  
  246.  
  247.