CharacterArray.st
changeset 14405 1d0d99a95bba
parent 14168 fb2ae640ab02
child 14420 b388916e6aed
equal deleted inserted replaced
14404:49a54ea47bf8 14405:1d0d99a95bba
   866 asUrl
   866 asUrl
   867     ^ self asURL
   867     ^ self asURL
   868 !
   868 !
   869 
   869 
   870 asWideString
   870 asWideString
       
   871     "return a two-byte string containing the same characters as the receiver"
       
   872 
   871     ^ self asTwoByteString
   873     ^ self asTwoByteString
   872 
   874 
   873     "
   875     "
   874      'abc' asWideString
   876      'abc' asWideString
   875     "
   877     "
   876 !
   878 !
   877 
   879 
   878 capitalized
   880 capitalized
       
   881     "same as asUppercaseFirst for Squeak compatibility"
       
   882 
   879     ^ self asUppercaseFirst
   883     ^ self asUppercaseFirst
   880 
   884 
   881     "
   885     "
   882      'hello' capitalized
   886      'hello' capitalized
   883     "
   887     "
   890 caseSensitiveLessOrEqual:aString
   894 caseSensitiveLessOrEqual:aString
   891     ^ self <= aString
   895     ^ self <= aString
   892 !
   896 !
   893 
   897 
   894 charactersExactlyMatching:aString
   898 charactersExactlyMatching:aString
       
   899     "return the number of characters I share as a prefix with the argument, aString"
       
   900 
   895     |idx nMax|
   901     |idx nMax|
   896 
   902 
   897     nMax :=(self size) min:(aString size).
   903     nMax :=(self size) min:(aString size).
   898     idx := 1.
   904     idx := 1.
   899     [idx <= nMax] whileTrue:[
   905     [idx <= nMax] whileTrue:[
   900 	(self at:idx) = (aString at:idx) ifFalse:[
   906         (self at:idx) = (aString at:idx) ifFalse:[
   901 	    ^ idx - 1
   907             ^ idx - 1
   902 	].
   908         ].
   903 	idx := idx + 1.
   909         idx := idx + 1.
   904     ].
   910     ].
   905     ^ nMax
   911     ^ nMax
   906 
   912 
   907     "
   913     "
   908      'abc' charactersExactlyMatching:'abc'
   914      'abc' charactersExactlyMatching:'abc'
  1010 
  1016 
  1011     "Created: / 05-09-2011 / 23:13:16 / cg"
  1017     "Created: / 05-09-2011 / 23:13:16 / cg"
  1012 !
  1018 !
  1013 
  1019 
  1014 lastSpacePosition
  1020 lastSpacePosition
       
  1021     "return the index of the last space character; 0 if there is none"
       
  1022 
  1015     ^ self lastIndexOfSeparator
  1023     ^ self lastIndexOfSeparator
  1016 !
  1024 !
  1017 
  1025 
  1018 padded:leftOrRight to:paddedSize with:padCharacter
  1026 padded:leftOrRight to:paddedSize with:padCharacter
  1019     "pad left (leftOrRight==#left) or right"
  1027     "pad left (leftOrRight==#left) or right"
  1551     "added for visual works compatibility"
  1559     "added for visual works compatibility"
  1552     ^ true
  1560     ^ true
  1553 ! !
  1561 ! !
  1554 
  1562 
  1555 
  1563 
       
  1564 
  1556 !CharacterArray methodsFor:'character searching'!
  1565 !CharacterArray methodsFor:'character searching'!
  1557 
  1566 
  1558 includesMatchCharacters
  1567 includesMatchCharacters
  1559     "return true if the receiver includes any GLOB meta-match characters (i.e. $* or $#)
  1568     "return true if the receiver includes any GLOB meta-match characters (i.e. $* or $#)
  1560      for match operations; false if not.
  1569      for match operations; false if not.
  3709     ^ encoder decodeString:self.
  3718     ^ encoder decodeString:self.
  3710 !
  3719 !
  3711 
  3720 
  3712 encodeFrom:oldEncoding into:newEncoding
  3721 encodeFrom:oldEncoding into:newEncoding
  3713     ^ CharacterEncoder encodeString:self from:oldEncoding into:newEncoding
  3722     ^ CharacterEncoder encodeString:self from:oldEncoding into:newEncoding
       
  3723 
       
  3724     "
       
  3725      'δόφ' encodeFrom:#iso8859 into:#utf8
       
  3726      ('δόφ' encodeFrom:#iso8859 into:#utf8) encodeFrom:#utf8 into:#unicode
       
  3727     "
  3714 !
  3728 !
  3715 
  3729 
  3716 rot13
  3730 rot13
  3717      "Usenet: from `rotate alphabet 13 places']
  3731      "Usenet: from `rotate alphabet 13 places']
  3718       The simple Caesar-cypher encryption that replaces each English
  3732       The simple Caesar-cypher encryption that replaces each English
  4640 
  4654 
  4641     ^ #unicode
  4655     ^ #unicode
  4642 !
  4656 !
  4643 
  4657 
  4644 hasChangeOfEmphasis
  4658 hasChangeOfEmphasis
       
  4659     "return true, if the receiver contains non-empty emphasis information
       
  4660      i.e. any non-normal (=emphasized) characters"
       
  4661 
  4645     ^ false
  4662     ^ false
  4646 
  4663 
  4647     "Created: 12.5.1996 / 12:31:39 / cg"
  4664     "Created: 12.5.1996 / 12:31:39 / cg"
  4648 !
  4665 !
  4649 
  4666 
  4977 
  4994 
  4978     "Modified: / 18-11-2010 / 15:43:28 / cg"
  4995     "Modified: / 18-11-2010 / 15:43:28 / cg"
  4979 !
  4996 !
  4980 
  4997 
  4981 firstLine
  4998 firstLine
  4982     ^ self asCollectionOfSubCollectionsSeparatedBy:Character cr do:[:line | ^ line].
  4999     "return the first line of a multiline string"
       
  5000 
       
  5001     ^ self asCollectionOfSubCollectionsSeparatedBy:(Character cr) do:[:line | ^ line].
  4983 
  5002 
  4984     "
  5003     "
  4985      'hello' firstLine
  5004      'hello' firstLine
  4986      '1\2\3' withCRs firstLine
  5005      '1\2\3' withCRs firstLine
  4987      '\1\2\3' withCRs firstLine
  5006      '\1\2\3' withCRs firstLine
  6078 ! !
  6097 ! !
  6079 
  6098 
  6080 !CharacterArray class methodsFor:'documentation'!
  6099 !CharacterArray class methodsFor:'documentation'!
  6081 
  6100 
  6082 version
  6101 version
  6083     ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.475 2012-07-10 07:39:54 stefan Exp $'
  6102     ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.476 2012-10-20 19:11:08 cg Exp $'
  6084 !
  6103 !
  6085 
  6104 
  6086 version_CVS
  6105 version_CVS
  6087     ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.475 2012-07-10 07:39:54 stefan Exp $'
  6106     ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.476 2012-10-20 19:11:08 cg Exp $'
  6088 ! !
  6107 ! !
  6089 
  6108 
  6090 CharacterArray initialize!
  6109 CharacterArray initialize!