CharacterArray.st
branchjv
changeset 18117 eb433f2c42b2
parent 18115 26ac4840e5d0
parent 15912 13b6b4a8109d
child 18120 e3a375d5f6a8
equal deleted inserted replaced
18116:bf7f37b63ea2 18117:eb433f2c42b2
   281 
   281 
   282     "Modified: 28.6.1997 / 20:09:35 / cg"
   282     "Modified: 28.6.1997 / 20:09:35 / cg"
   283     "Created: 3.8.1997 / 18:16:40 / cg"
   283     "Created: 3.8.1997 / 18:16:40 / cg"
   284 ! !
   284 ! !
   285 
   285 
       
   286 
   286 !CharacterArray class methodsFor:'cleanup'!
   287 !CharacterArray class methodsFor:'cleanup'!
   287 
   288 
   288 lowSpaceCleanup
   289 lowSpaceCleanup
   289     "cleanup in low-memory situations"
   290     "cleanup in low-memory situations"
   290 
   291 
   323    invalid:
   324    invalid:
   324      CharacterArray fromUTF8Bytes:#[ 16rC0 16r80 ]
   325      CharacterArray fromUTF8Bytes:#[ 16rC0 16r80 ]
   325      CharacterArray fromUTF8Bytes:#[ 16rE0 16r80 16r80 ]
   326      CharacterArray fromUTF8Bytes:#[ 16rE0 16r80 16r80 ]
   326     "
   327     "
   327 ! !
   328 ! !
       
   329 
   328 
   330 
   329 !CharacterArray class methodsFor:'pattern matching'!
   331 !CharacterArray class methodsFor:'pattern matching'!
   330 
   332 
   331 matchEscapeCharacter
   333 matchEscapeCharacter
   332     "return the character used to escape a matchCharacter
   334     "return the character used to escape a matchCharacter
   721      Abstract subclasses must redefine again."
   723      Abstract subclasses must redefine again."
   722 
   724 
   723     ^ self == CharacterArray
   725     ^ self == CharacterArray
   724 ! !
   726 ! !
   725 
   727 
       
   728 
   726 !CharacterArray methodsFor:'Compatibility-ANSI'!
   729 !CharacterArray methodsFor:'Compatibility-ANSI'!
   727 
   730 
   728 addLineDelimiters
   731 addLineDelimiters
   729     "Ansi compatibility - same as withCRs"
   732     "Ansi compatibility - same as withCRs"
   730 
   733 
  1611 isCharacters
  1614 isCharacters
  1612     "added for visual works compatibility"
  1615     "added for visual works compatibility"
  1613     ^ true
  1616     ^ true
  1614 ! !
  1617 ! !
  1615 
  1618 
       
  1619 
  1616 !CharacterArray methodsFor:'character searching'!
  1620 !CharacterArray methodsFor:'character searching'!
  1617 
  1621 
  1618 includesMatchCharacters
  1622 includesMatchCharacters
  1619     "return true if the receiver includes any GLOB meta-match characters (i.e. $* or $#)
  1623     "return true if the receiver includes any GLOB meta-match characters (i.e. $* or $#)
  1620      for match operations; false if not.
  1624      for match operations; false if not.
  1768     "
  1772     "
  1769      'hello world' indexOfSeparator
  1773      'hello world' indexOfSeparator
  1770      'helloworld' indexOfSeparator
  1774      'helloworld' indexOfSeparator
  1771      'hello   ' indexOfSeparator
  1775      'hello   ' indexOfSeparator
  1772      '   hello' indexOfSeparator
  1776      '   hello' indexOfSeparator
       
  1777     "
       
  1778 !
       
  1779 
       
  1780 indexOfSeparatorOrEndStartingAt:startIndex
       
  1781     "return the index of the next whitespace character,
       
  1782      starting the search at startIndex, searching forward;
       
  1783      return the index of one behond the end of the receiver if no separator was found.
       
  1784      To extract the word, copy from startIndex to the returned index-1"
       
  1785 
       
  1786     |idx|
       
  1787 
       
  1788     idx := self indexOfSeparatorStartingAt:startIndex.
       
  1789     idx == 0 ifTrue:[^ self size + 1].
       
  1790     ^ idx.
       
  1791 
       
  1792     "
       
  1793      'hello world' indexOfSeparatorOrEndStartingAt:3    
       
  1794      ' hello world' indexOfSeparatorOrEndStartingAt:3
       
  1795      'hello world ' indexOfSeparatorOrEndStartingAt:3
       
  1796      'hello world ' indexOfSeparatorOrEndStartingAt:6
       
  1797      'hello world ' indexOfSeparatorOrEndStartingAt:7
       
  1798      'helloworld ' indexOfSeparatorOrEndStartingAt:7    
       
  1799      'helloworld' indexOfSeparatorOrEndStartingAt:7
  1773     "
  1800     "
  1774 !
  1801 !
  1775 
  1802 
  1776 indexOfSeparatorStartingAt:startIndex
  1803 indexOfSeparatorStartingAt:startIndex
  1777     "return the index of the next whitespace character,
  1804     "return the index of the next whitespace character,
  3896 
  3923 
  3897 encodeFrom:oldEncoding into:newEncoding
  3924 encodeFrom:oldEncoding into:newEncoding
  3898     ^ CharacterEncoder encodeString:self from:oldEncoding into:newEncoding
  3925     ^ CharacterEncoder encodeString:self from:oldEncoding into:newEncoding
  3899 
  3926 
  3900     "
  3927     "
  3901      'äüö' encodeFrom:#iso8859 into:#utf8
  3928      '' encodeFrom:#iso8859 into:#utf8
  3902      ('äüö' encodeFrom:#iso8859 into:#utf8) encodeFrom:#utf8 into:#unicode
  3929      ('' encodeFrom:#iso8859 into:#utf8) encodeFrom:#utf8 into:#unicode
  3903     "
  3930     "
  3904 !
  3931 !
  3905 
  3932 
  3906 rot13
  3933 rot13
  3907      "Usenet: from `rotate alphabet 13 places']
  3934      "Usenet: from `rotate alphabet 13 places']
  3953     s nextPutAllUtf16:self.
  3980     s nextPutAllUtf16:self.
  3954     ^ s contents
  3981     ^ s contents
  3955 
  3982 
  3956     "
  3983     "
  3957      'abcde1234' utf16Encoded
  3984      'abcde1234' utf16Encoded
  3958      'abcdeäöüß' utf16Encoded
  3985      'abcde' utf16Encoded
  3959     "
  3986     "
  3960 
  3987 
  3961     "Modified: / 11-05-2010 / 19:12:37 / cg"
  3988     "Modified: / 11-05-2010 / 19:12:37 / cg"
  3962 !
  3989 !
  3963 
  3990 
  4040     s nextPutAllUtf8:self.
  4067     s nextPutAllUtf8:self.
  4041     ^ s contents
  4068     ^ s contents
  4042 
  4069 
  4043     "
  4070     "
  4044      'abcde1234' utf8Encoded
  4071      'abcde1234' utf8Encoded
  4045      'abcdeäöüß' utf8Encoded
  4072      'abcde' utf8Encoded
  4046     "
  4073     "
  4047 
  4074 
  4048     "Modified: / 11-05-2010 / 19:12:37 / cg"
  4075     "Modified: / 11-05-2010 / 19:12:37 / cg"
  4049 ! !
  4076 ! !
       
  4077 
       
  4078 
  4050 
  4079 
  4051 !CharacterArray methodsFor:'matching - glob expressions'!
  4080 !CharacterArray methodsFor:'matching - glob expressions'!
  4052 
  4081 
  4053 compoundMatch:aString
  4082 compoundMatch:aString
  4054     "like match, but the receiver may be a compound match pattern,
  4083     "like match, but the receiver may be a compound match pattern,
  4727 
  4756 
  4728     ^ aPatternString match:self caseSensitive:ignoreCase not
  4757     ^ aPatternString match:self caseSensitive:ignoreCase not
  4729 
  4758 
  4730     "Created: / 08-03-2012 / 03:11:11 / cg"
  4759     "Created: / 08-03-2012 / 03:11:11 / cg"
  4731 ! !
  4760 ! !
       
  4761 
  4732 
  4762 
  4733 !CharacterArray methodsFor:'padded copying'!
  4763 !CharacterArray methodsFor:'padded copying'!
  4734 
  4764 
  4735 centerPaddedTo:newSize
  4765 centerPaddedTo:newSize
  4736      "return a new string consisting of the receivers characters,
  4766      "return a new string consisting of the receivers characters,
  5354     "
  5384     "
  5355 
  5385 
  5356     "Created: 12.5.1996 / 20:09:29 / cg"
  5386     "Created: 12.5.1996 / 20:09:29 / cg"
  5357     "Modified: 17.4.1997 / 12:50:23 / cg"
  5387     "Modified: 17.4.1997 / 12:50:23 / cg"
  5358 ! !
  5388 ! !
       
  5389 
  5359 
  5390 
  5360 !CharacterArray methodsFor:'special string converting'!
  5391 !CharacterArray methodsFor:'special string converting'!
  5361 
  5392 
  5362 expandPlaceholders:escapeCharacter with:argArrayOrDictionary
  5393 expandPlaceholders:escapeCharacter with:argArrayOrDictionary
  5363     "this is the generic version of the old %-escaping method, allowing for an arbitrary
  5394     "this is the generic version of the old %-escaping method, allowing for an arbitrary
  6299      ('  ' , Character tab asString , ' foo   ') withoutTrailingSeparators inspect
  6330      ('  ' , Character tab asString , ' foo   ') withoutTrailingSeparators inspect
  6300      ('   foo' , Character tab asString) withoutTrailingSeparators inspect
  6331      ('   foo' , Character tab asString) withoutTrailingSeparators inspect
  6301     "
  6332     "
  6302 ! !
  6333 ! !
  6303 
  6334 
       
  6335 
  6304 !CharacterArray methodsFor:'substring searching'!
  6336 !CharacterArray methodsFor:'substring searching'!
  6305 
  6337 
  6306 findRangeOfString:subString
  6338 findRangeOfString:subString
  6307     "find a substring. if found, return the start- and endIndex;
  6339     "find a substring. if found, return the start- and endIndex;
  6308      if not found, return an empty interval."
  6340      if not found, return an empty interval."
  6884 ! !
  6916 ! !
  6885 
  6917 
  6886 !CharacterArray class methodsFor:'documentation'!
  6918 !CharacterArray class methodsFor:'documentation'!
  6887 
  6919 
  6888 version
  6920 version
  6889     ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.520 2014-01-05 12:27:34 cg Exp $'
  6921     ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.521 2014-01-27 22:59:16 cg Exp $'
  6890 !
  6922 !
  6891 
  6923 
  6892 version_CVS
  6924 version_CVS
  6893     ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.520 2014-01-05 12:27:34 cg Exp $'
  6925     ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.521 2014-01-27 22:59:16 cg Exp $'
  6894 !
  6926 !
  6895 
  6927 
  6896 version_HG
  6928 version_HG
  6897 
  6929 
  6898     ^ '$Changeset: <not expanded> $'
  6930     ^ '$Changeset: <not expanded> $'