equal
deleted
inserted
replaced
3483 " |
3483 " |
3484 |
3484 |
3485 "Modified (comment): / 03-02-2019 / 13:08:15 / Claus Gittinger" |
3485 "Modified (comment): / 03-02-2019 / 13:08:15 / Claus Gittinger" |
3486 ! |
3486 ! |
3487 |
3487 |
|
3488 asDenseUnicodeString |
|
3489 "return the receiver as single-byte, double byte or 4-byte unicode string, |
|
3490 depending on the number of bits required to hold all characters in myself. |
|
3491 Use this to extract non-wide parts from a wide string, |
|
3492 i.e. after a substring has been copied out of a wide string" |
|
3493 |
|
3494 |nb| |
|
3495 |
|
3496 nb := self bytesPerCharacterNeeded. |
|
3497 (nb ~~ self bytesPerCharacter) ifTrue:[ |
|
3498 nb == 1 ifTrue:[ |
|
3499 ^ self asSingleByteString |
|
3500 ]. |
|
3501 nb == 2 ifTrue:[ |
|
3502 ^ self asUnicode16String |
|
3503 ]. |
|
3504 ]. |
|
3505 ^ self |
|
3506 |
|
3507 " |
|
3508 'abc' asUnicode16String asDenseUnicodeString |
|
3509 'abc' asUnicode32String asDenseUnicodeString |
|
3510 ('abc',(Character value:16r165)) asDenseUnicodeString |
|
3511 ('abc',(Character value:16r165)) asUnicode32String asDenseUnicodeString |
|
3512 " |
|
3513 |
|
3514 "Created: / 25-03-2019 / 16:28:02 / Claus Gittinger" |
|
3515 ! |
|
3516 |
3488 asFilename |
3517 asFilename |
3489 "return a Filename with pathname taken from the receiver" |
3518 "return a Filename with pathname taken from the receiver" |
3490 |
3519 |
3491 ^ Filename named:self "(self asSingleByteStringReplaceInvalidWith:$?)" |
3520 ^ Filename named:self "(self asSingleByteStringReplaceInvalidWith:$?)" |
3492 |
3521 |
6432 'hello' asText allBold bitsPerCharacter |
6461 'hello' asText allBold bitsPerCharacter |
6433 " |
6462 " |
6434 ! |
6463 ! |
6435 |
6464 |
6436 bytesPerCharacter |
6465 bytesPerCharacter |
6437 "return the underlying string's required |
6466 "return the underlying string's bytesPerCharacter |
6438 bytesPerCharacter |
|
6439 (i.e. is it a regular String or a TwoByteString)" |
6467 (i.e. is it a regular String or a TwoByteString)" |
6440 |
6468 |
6441 |string max| |
6469 |string max| |
6442 |
6470 |
6443 (string := self string) ~~ self ifTrue:[ |
6471 (string := self string) ~~ self ifTrue:[ |
6453 " |
6481 " |
6454 'hello' bytesPerCharacter |
6482 'hello' bytesPerCharacter |
6455 'hello' asUnicode16String bytesPerCharacter |
6483 'hello' asUnicode16String bytesPerCharacter |
6456 'hello' asText allBold bytesPerCharacter |
6484 'hello' asText allBold bytesPerCharacter |
6457 " |
6485 " |
|
6486 |
|
6487 "Modified (comment): / 25-03-2019 / 16:24:02 / Claus Gittinger" |
|
6488 ! |
|
6489 |
|
6490 bytesPerCharacterNeeded |
|
6491 "return the actual underlying string's required bytesPerCharacter |
|
6492 (i.e. checks if all characters really need that depth)" |
|
6493 |
|
6494 |string max mySize| |
|
6495 |
|
6496 (string := self string) ~~ self ifTrue:[ |
|
6497 ^ string bytesPerCharacterNeeded |
|
6498 ]. |
|
6499 |
|
6500 mySize := self bytesPerCharacter. |
|
6501 |
|
6502 max := 1. |
|
6503 self do:[:eachCharacter | |
|
6504 max := max max:(eachCharacter bytesPerCharacter). |
|
6505 max == mySize ifTrue:[^ max]. |
|
6506 ]. |
|
6507 ^ max |
|
6508 |
|
6509 " |
|
6510 'hello' bytesPerCharacter -> 1 |
|
6511 'hello' bytesPerCharacterNeeded -> 1 |
|
6512 |
|
6513 'hello' asUnicode16String bytesPerCharacter -> 2 |
|
6514 'hello' asUnicode16String bytesPerCharacterNeeded -> 1 |
|
6515 " |
|
6516 |
|
6517 "Created: / 25-03-2019 / 16:22:00 / Claus Gittinger" |
6458 ! |
6518 ! |
6459 |
6519 |
6460 characterSize |
6520 characterSize |
6461 "answer the size in bits of my largest character (actually only 7, 8, 16 or 32)" |
6521 "answer the size in bits of my largest character (actually only 7, 8, 16 or 32)" |
6462 |
6522 |