CharacterArray.st
changeset 22525 ea97c9efdaed
parent 22451 0748418b3412
child 22528 b54ce63c47f7
equal deleted inserted replaced
22524:be41e4a8c1aa 22525:ea97c9efdaed
  1016     characterSize <= 8 ifTrue:[^ String].
  1016     characterSize <= 8 ifTrue:[^ String].
  1017     characterSize <= 16 ifTrue:[^ Unicode16String].
  1017     characterSize <= 16 ifTrue:[^ Unicode16String].
  1018     ^ Unicode32String
  1018     ^ Unicode32String
  1019 ! !
  1019 ! !
  1020 
  1020 
       
  1021 
       
  1022 !CharacterArray class methodsFor:'utilities'!
       
  1023 
       
  1024 withoutAmpersandEscapes:label
       
  1025     "remove single ampersands;
       
  1026      replace double ampersands by single ones.
       
  1027      This is used to unescape menu-labels 
       
  1028      (which use the ampersand as shortKey marker)"
       
  1029 
       
  1030     ^ String 
       
  1031         streamContents:[:out |
       
  1032             |in ch next|
       
  1033 
       
  1034             in := label readStream.
       
  1035             [in atEnd] whileFalse:[
       
  1036                 ch := in next.
       
  1037                 ch == $& ifTrue:[
       
  1038                     (next := in peek) == $& ifTrue:[
       
  1039                         in next.
       
  1040                         out nextPut:ch
       
  1041                     ] ifFalse:[
       
  1042                         ch := next
       
  1043                     ].
       
  1044                 ] ifFalse:[
       
  1045                     out nextPut:ch
       
  1046                 ].
       
  1047             ]
       
  1048         ]
       
  1049 
       
  1050     "
       
  1051      String withoutAmpersandEscapes:''
       
  1052      String withoutAmpersandEscapes:'a'
       
  1053      String withoutAmpersandEscapes:'abcd'
       
  1054      String withoutAmpersandEscapes:'&abcd'
       
  1055      String withoutAmpersandEscapes:'&abcd&'
       
  1056      String withoutAmpersandEscapes:'&a&b&c&d'
       
  1057      String withoutAmpersandEscapes:'&a&b&c&d&'
       
  1058      String withoutAmpersandEscapes:'&&a&&b&&c&&d&&'
       
  1059      String withoutAmpersandEscapes:'&&a&&b&&c&&d&'
       
  1060      String withoutAmpersandEscapes:'&a&&b&&c&&d&'
       
  1061      String withoutAmpersandEscapes:'a&&b&&c&&d'
       
  1062     "
       
  1063 ! !
  1021 
  1064 
  1022 !CharacterArray methodsFor:'Compatibility-ANSI'!
  1065 !CharacterArray methodsFor:'Compatibility-ANSI'!
  1023 
  1066 
  1024 addLineDelimiters
  1067 addLineDelimiters
  1025     "Ansi compatibility - same as withCRs"
  1068     "Ansi compatibility - same as withCRs"