644 (encoding is something like #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc)" |
644 (encoding is something like #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc)" |
645 |
645 |
646 ^ characterEncoding |
646 ^ characterEncoding |
647 ! |
647 ! |
648 |
648 |
649 characterEncoding:encodingSymOrNil |
649 characterEncoding:encodingArg |
650 "define how the contents is encoded internally. |
650 "define how the contents is encoded internally. |
651 For now, this should be the same encoding as my fonts encoding |
651 This should normally never be required, as ST/X now assumes |
652 (otherwise, mappings would occur when drawing). |
652 unicode (of which iso8859-1 is a subset) encoding. |
653 This is (currently) only passed down from the fileBrowser, |
653 The possibility to change the characterEncoding is provided as |
654 and required when japanese/chinese/korean text is edited. |
654 a backward compatibility hook for programs which want to use |
655 (encoding is something like #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc)" |
655 another encoding internally." |
656 |
656 |
657 characterEncoding := encodingSymOrNil |
657 |encodingSymOrNil| |
|
658 |
|
659 encodingSymOrNil := encodingArg isNil ifTrue:[#'iso10646-1'] ifFalse:[encodingArg asSymbol]. |
|
660 |
|
661 characterEncoding ~~ encodingSymOrNil ifTrue:[ |
|
662 "/ TODO: reencode contents if required. |
|
663 (list size ~~ 0 |
|
664 and:[ list contains:[:line | line size > 0]]) ifTrue:[ |
|
665 (self confirm:'Your text may need to be re-coded - this is not yet supported.\\Proceed ?') |
|
666 ifFalse:[^ self]. |
|
667 ]. |
|
668 characterEncoding := encodingSymOrNil. |
|
669 ]. |
658 ! |
670 ! |
659 |
671 |
660 characterPositionOfSelection |
672 characterPositionOfSelection |
661 "return the character index of the first character in the selection. |
673 "return the character index of the first character in the selection. |
662 Returns 0 if there is no selection." |
674 Returns 0 if there is no selection." |
704 ! |
716 ! |
705 |
717 |
706 externalEncoding:encodingSymOrNil |
718 externalEncoding:encodingSymOrNil |
707 "define how the contents should be encoded when saved |
719 "define how the contents should be encoded when saved |
708 via the 'save / save as' dialog. |
720 via the 'save / save as' dialog. |
709 This is (currently) only passed down from the fileBrowser, |
721 This is (currently only) passed down from the fileBrowser, |
710 and required when japanese/chinese/korean text is edited. |
722 and required when utf8/japanese/chinese/korean text is edited. |
711 (encoding is something like #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc)" |
723 (encoding is something like #utf8 #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc). |
|
724 Notice: this only affects the external representation of the text." |
712 |
725 |
713 externalEncoding := encodingSymOrNil |
726 externalEncoding := encodingSymOrNil |
714 ! |
727 ! |
715 |
728 |
716 parenthesisSpecification |
729 parenthesisSpecification |
1017 self warn:'Your display does not seem to provide any ' , newEncoding allBold , ' encoded font.\\Please select an appropriate font (iso10646-Unicode recommended)'. |
1030 self warn:'Your display does not seem to provide any ' , newEncoding allBold , ' encoded font.\\Please select an appropriate font (iso10646-Unicode recommended)'. |
1018 pref := #'iso10646-1'. |
1031 pref := #'iso10646-1'. |
1019 ] |
1032 ] |
1020 ]. |
1033 ]. |
1021 |
1034 |
1022 msg := 'switch to a %1 encoded font ?'. |
1035 msg := 'Switch to a %1 encoded font ?'. |
1023 (ask not or:[self confirm:(resources string:msg with:pref) withCRs]) |
1036 (ask not or:[self confirm:(resources string:msg with:pref) withCRs]) |
1024 ifTrue:[ |
1037 ifTrue:[ |
1025 self withWaitCursorDo:[ |
1038 self withWaitCursorDo:[ |
1026 f := FontPanel |
1039 f := FontPanel |
1027 fontFromUserInitial:defaultFont |
1040 fontFromUserInitial:defaultFont |
2000 leading spaces will be replaced by tab-characters in the output." |
2011 leading spaces will be replaced by tab-characters in the output." |
2001 |
2012 |
2002 |startNr nLines string encoder| |
2013 |startNr nLines string encoder| |
2003 |
2014 |
2004 encoder := CharacterEncoder encoderToEncodeFrom:characterEncoding into:encodingSymOrNil. |
2015 encoder := CharacterEncoder encoderToEncodeFrom:characterEncoding into:encodingSymOrNil. |
|
2016 |
2005 aStream isFileStream ifTrue:[ |
2017 aStream isFileStream ifTrue:[ |
2006 "on some systems, writing linewise is very slow (via NFS) |
2018 "on some systems, writing linewise is very slow (via NFS) |
2007 therefore we convert to a string and write it in big chunks. |
2019 therefore we convert to a string and write it in big chunks. |
2008 To avoid creating huge strings, we do it in blocks of 1000 lines, |
2020 To avoid creating huge strings, we do it in blocks of 1000 lines, |
2009 limiting temporary string creation to about 50-80k. |
2021 limiting temporary string creation to about 50-80k. |