SCI_SEARCHINTARGET not finding Unicode characters

61 views
Skip to first unread message

Roland Smith

unread,
Nov 11, 2017, 10:40:46 AM11/11/17
to scintilla-interest
I am using version 3.7.5 from PowerBuilder which is always Unicode.

My problem is that when editing Unicode files, I can only find normal strings. I am trying to find » (C2 BB) and it returns -1. I have tried Notepad++ (version 3.5.6 of SciLexer.dll) and it finds the string so apparently I am doing something wrong.

This is the declaration of the function I am using to send the SCI_SEARCHINTARGET command:

Function long SciSendBlob(long hSciWnd, uint Msg, long wParam, Ref blob lParam) Library "SciLexer.dll" Alias For "Scintilla_DirectFunction"

Before calling the function, I convert the search string into a UTF8 blob. I have verified that the blob is two bytes long but the debugger doesn't show contents of blob variables.

Before loading the file with SCI_SETTEXT I set code page to 65001. Is there another command I should use to set it to Unicode mode?

Thanks!

Neil Hodgson

unread,
Nov 11, 2017, 5:17:16 PM11/11/17
to Scintilla mailing list
Roland Smith:

> My problem is that when editing Unicode files, I can only find normal strings. I am trying to find » (C2 BB) and it returns -1. I have tried Notepad++ (version 3.5.6 of SciLexer.dll) and it finds the string so apparently I am doing something wrong.
>
> This is the declaration of the function I am using to send the SCI_SEARCHINTARGET command:
>
> Function long SciSendBlob(long hSciWnd, uint Msg, long wParam, Ref blob lParam) Library "SciLexer.dll" Alias For "Scintilla_DirectFunction"
>
> Before calling the function, I convert the search string into a UTF8 blob. I have verified that the blob is two bytes long but the debugger doesn't show contents of blob variables.

Its unclear to me what a blob is in this context and whether there is a pointer or a pointer-to-pointer. It may be possible to start a debugger (such as Visual Studio) on the Scintilla DLL as called by an application. One way is to place a call to DebugBreak inside a recompiled version of Scintilla and choose the JIT debug options when they appear. Then check what Scintilla is seeing as he arguments to SCI_SEARCHINTARGET.

Or add some logging to SCI_SEARCHINTARGET to print out the text and length to the debug console with OutputDebugString.

Neil

Roland Smith

unread,
Nov 11, 2017, 5:30:10 PM11/11/17
to scintilla-interest
In PowerBuilder blob is a datatype that can contain any binary data. PowerBuilder strings are UTF16LE so I have to convert it from a string to a blob containing UTF8 representation of the string. The keyword 'Ref' in the function declaration means that it is passing a pointer.

This works perfectly fine searching for normal characters but if the search value contains a double byte character, it doesn't find it.

Roland Smith

unread,
Nov 11, 2017, 9:50:28 PM11/11/17
to scintilla-interest
 I figured out my problem. I was passing 1 for length instead of 2.


Reply all
Reply to author
Forward
0 new messages