Character.st
changeset 18268 70af591a198c
parent 18240 28af09029a8b
child 18274 042d13555f1f
child 18298 541b114e644a
equal deleted inserted replaced
18267:3bc0c58cb8e9 18268:70af591a198c
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  COPYRIGHT (c) 1988 by Claus Gittinger
     4  COPYRIGHT (c) 1988 by Claus Gittinger
     3 	      All Rights Reserved
     5 	      All Rights Reserved
     4 
     6 
     5  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
   322     "return a character with codePoint anInteger - backward compatibility"
   324     "return a character with codePoint anInteger - backward compatibility"
   323 
   325 
   324     ^ self codePoint:anInteger
   326     ^ self codePoint:anInteger
   325 ! !
   327 ! !
   326 
   328 
       
   329 
   327 !Character class methodsFor:'accessing untypeable characters'!
   330 !Character class methodsFor:'accessing untypeable characters'!
   328 
   331 
   329 controlCharacter:char
   332 controlCharacter:char
   330     "Answer the Character representing ctrl-char.
   333     "Answer the Character representing ctrl-char.
   331      ctrl-a -> 1; ctrl-@ -> 0"
   334      ctrl-a -> 1; ctrl-@ -> 0"
   367 rightParenthesis
   370 rightParenthesis
   368     "Answer the Character representing a right parenthesis."
   371     "Answer the Character representing a right parenthesis."
   369 
   372 
   370     ^ self codePoint:41
   373     ^ self codePoint:41
   371 ! !
   374 ! !
       
   375 
   372 
   376 
   373 !Character class methodsFor:'constants'!
   377 !Character class methodsFor:'constants'!
   374 
   378 
   375 backspace
   379 backspace
   376     "return the backspace character"
   380     "return the backspace character"
   605     "
   609     "
   606      Character separators
   610      Character separators
   607     "
   611     "
   608 ! !
   612 ! !
   609 
   613 
       
   614 
   610 !Character methodsFor:'Compatibility-Dolphin'!
   615 !Character methodsFor:'Compatibility-Dolphin'!
   611 
   616 
   612 isAlphaNumeric
   617 isAlphaNumeric
   613     "Compatibility method - do not use in new code.
   618     "Compatibility method - do not use in new code.
   614      Return true, if I am a letter or a digit
   619      Return true, if I am a letter or a digit
   651       or:[ (asciivalue between:123 and:126)
   656       or:[ (asciivalue between:123 and:126)
   652       or:[ (asciivalue between:161 and:191)
   657       or:[ (asciivalue between:161 and:191)
   653       or:[ (asciivalue == 215 )
   658       or:[ (asciivalue == 215 )
   654       or:[ (asciivalue == 247 ) ]]]]]
   659       or:[ (asciivalue == 247 ) ]]]]]
   655 ! !
   660 ! !
       
   661 
   656 
   662 
   657 !Character methodsFor:'accessing'!
   663 !Character methodsFor:'accessing'!
   658 
   664 
   659 codePoint
   665 codePoint
   660     "return the codePoint of myself.
   666     "return the codePoint of myself.
  1453     s := WriteStream on:(String new:6).
  1459     s := WriteStream on:(String new:6).
  1454     s nextPutUtf8:self.
  1460     s nextPutUtf8:self.
  1455     ^ s contents
  1461     ^ s contents
  1456 
  1462 
  1457     "
  1463     "
  1458 	'ä' utf8Encoded
  1464 	'ä' utf8Encoded
  1459     "
  1465     "
  1460 ! !
  1466 ! !
  1461 
  1467 
  1462 !Character methodsFor:'copying'!
  1468 !Character methodsFor:'copying'!
  1463 
  1469 
  2499     RETURN (__MKUCHARACTER(val)) ;
  2505     RETURN (__MKUCHARACTER(val)) ;
  2500 %}
  2506 %}
  2501 
  2507 
  2502     "
  2508     "
  2503      $e asNonDiacritical
  2509      $e asNonDiacritical
  2504      $é asNonDiacritical
  2510      $é asNonDiacritical
  2505      $ä asNonDiacritical
  2511      $ä asNonDiacritical
  2506      $å asNonDiacritical
  2512      $Ã¥ asNonDiacritical
  2507     "
  2513     "
  2508 !
  2514 !
  2509 
  2515 
  2510 isNationalAlphaNumeric
  2516 isNationalAlphaNumeric
  2511     "return true, if the receiver is a letter or digit in the
  2517     "return true, if the receiver is a letter or digit.
  2512      current language (Language variable)"
  2518      This assumes unicode encoding."
  2513 
  2519 
  2514     self isNationalLetter ifTrue:[^ true].
  2520     ^ self isNationalLetter or:[self isNationalDigit]
  2515     ^ self isNationalDigit
       
  2516 !
  2521 !
  2517 
  2522 
  2518 isNationalDigit
  2523 isNationalDigit
  2519     "return true, if the receiver is a digit.
  2524     "return true, if the receiver is a digit.
  2520      This assumes unicode encoding.
  2525      This assumes unicode encoding.
  2523     |codePoint "{ Class SmallInteger }"|
  2528     |codePoint "{ Class SmallInteger }"|
  2524 
  2529 
  2525     codePoint := asciivalue.
  2530     codePoint := asciivalue.
  2526 
  2531 
  2527     codePoint <= 16rFF ifTrue:[                "/ u00xx - unicode latin1 page
  2532     codePoint <= 16rFF ifTrue:[                "/ u00xx - unicode latin1 page
  2528 	(codePoint between:($0 codePoint) and:($9 codePoint)) ifTrue:[^ true].
  2533         ^ codePoint between:$0 codePoint and:$9 codePoint.
  2529 	^ false
       
  2530     ].
  2534     ].
  2531 
  2535 
  2532     (codePoint between:16rFF10 and:16rFF19) ifTrue:[ ^ true].
  2536     ^ codePoint between:16rFF10 and:16rFF19
  2533     ^ false.
       
  2534 !
  2537 !
  2535 
  2538 
  2536 isNationalLetter
  2539 isNationalLetter
  2537     "return true, if the receiver is a letter.
  2540     "return true, if the receiver is a letter.
  2538      CAVEAT:
  2541      CAVEAT:
  3033 ! !
  3036 ! !
  3034 
  3037 
  3035 !Character class methodsFor:'documentation'!
  3038 !Character class methodsFor:'documentation'!
  3036 
  3039 
  3037 version
  3040 version
  3038     ^ '$Header: /cvs/stx/stx/libbasic/Character.st,v 1.161 2015-04-20 10:48:54 cg Exp $'
  3041     ^ '$Header: /cvs/stx/stx/libbasic/Character.st,v 1.162 2015-04-22 17:38:30 stefan Exp $'
  3039 !
  3042 !
  3040 
  3043 
  3041 version_CVS
  3044 version_CVS
  3042     ^ '$Header: /cvs/stx/stx/libbasic/Character.st,v 1.161 2015-04-20 10:48:54 cg Exp $'
  3045     ^ '$Header: /cvs/stx/stx/libbasic/Character.st,v 1.162 2015-04-22 17:38:30 stefan Exp $'
  3043 ! !
  3046 ! !
       
  3047