> I try to write some code in lua:
>
> print(props["CurrentSelection"])
>
> Then, if the seletion includes some Chinese code, the output is
> Garbage characters...
>
> How can I deal with the problem?
Use the same code page for the output pane as the edit pane.
Neil
> The properties of code page are already the same.
> code.page=936
> output.code.page=936
> and, I'd try to use
> code.page=65001
> output.code.page=65001
> then I got correct Chinese in props["CurrentSelection"].
command.input, $(CurrentSelection) and $(CurrentWord) always returns the text regardless of the code.page exclusively in UTF encoding.
This bug fixed in a long time SciTE-Ru http://scite-ru.googlecode.com/svn/trunk/pack/doc/SciTE-Ru_Kernel.html#SelectionErr
Must replace lines in SciTEBase.cxx
--------------------------------------------------------------
void SciTEBase::SelectionIntoProperties() {
SString currentSelection = SelectionExtend(0, false);
props.Set("CurrentSelection", currentSelection.c_str());
SString word = SelectionWord();
props.Set("CurrentWord", word.c_str());
--------------------------------------------------------------
such
--------------------------------------------------------------
void SciTEBase::SelectionIntoProperties() {
SString currentSelection = EncodeString(SelectionExtend(0, false));
props.Set("CurrentSelection", currentSelection.c_str());
SString word = EncodeString(SelectionWord());
props.Set("CurrentWord", word.c_str());
--------------------------------------------------------------
> One more thing,I found the feature of 'Open Selected Filename '
> doesn't work for Chinese(65001 or 936).
It is possible that to correct this bug to make the same change in
another place (SelectionFilename) ?
--
mozers
<http://scite.net.ru>
My assumption was correct.
Must replace line in SciTEBase.cxx
--------------------------------------------------------------
SString SciTEBase::SelectionFilename() {
return SelectionExtend(&SciTEBase::isfilenamecharforsel);
}
--------------------------------------------------------------
such
--------------------------------------------------------------
SString SciTEBase::SelectionFilename() {
return EncodeString(SelectionExtend(&SciTEBase::isfilenamecharforsel));
}
--------------------------------------------------------------
Now everything works well.
--
mozers
<http://scite.net.ru>
> The properties of code page are already the same.
> code.page=936
> output.code.page=936
>
> and, I'd try to use
> code.page=65001
> output.code.page=65001
>
> then I got correct Chinese in props["CurrentSelection"].
There is a conversion into UTF-8 caused by this code being used to
fill in the search dialogs. You can use
text, length = editor:GetSelText()
print(text)
Neil
> such
> --------------------------------------------------------------
> SString SciTEBase::SelectionFilename() {
> return EncodeString(SelectionExtend(&SciTEBase::isfilenamecharforsel));
> }
> --------------------------------------------------------------
> Now everything works well.
That will only work if the document encoding is the same as the
default platform encoding.
Neil
> That will only work if the document encoding is the same as the
> default platform encoding.
I agree.
My patch - is not ideal. But it works in 90% of cases.
The remained 10% should think up the best decision :)
--
mozers
<http://scite.net.ru>