Unable to create a text editor!

More basic than that, it is Hello World !

The Open button use the TextInputStream first code snippet:

Var f As FolderItem = FolderItem.ShowOpenFileDialog("text") // as defined in File Type Sets Editor
If f <> Nil Then
  If f.Exists Then
    // Be aware that TextInputStream.Open could raise an exception
    Var t As TextInputStream
    Try
      t = TextInputStream.Open(f)
      t.Encoding = Encodings.UTF8
      TA.Text = t.ReadAll
    Catch e As IOException
      MessageBox("Error accessing file.")
    End Try
    t.Close
  End If
End If

The Search button:

Var Search As String = DefineEncoding(TF_Search.Text, Encodings.UTF8)

If InStrB(TA.Text, TF_Search.Text) > 0 Then
  MsgBox "InStrB() found it !"
End If


If InStrB(TA.Text, TF_Search.Text) > 0 Then
  MsgBox "InStr() found it !"
End If

I typed vallée from the keyboard and get no result (yes, I could use System.DebugLog…)

Of course, if I Copy / Paste vallée from the TextArea, it is found.

M1 / Big Sur 11.2.3 / XOjo 2021r1.

Screen shot:

was the idea here this?

Var Search As String = DefineEncoding(TF_Search.Text, Encodings.UTF8)

If InStrB(TA.Text, Search ) > 0 Then

and why do you use InStrB and not InStr ?

That was the idea. A car must have made noise when I was typing the code…

I modified the code, but same result.

The idea was to be sure I get that with the same encoding.

The text file was created in the same computer once I finished to type the code (when I needed it). I copied folder names from the Finder and pasted that in TextEdit, the n save to disk. No fancy stuff have been done. Just what I wrote above.

The hard disk where the folders resides is usually connected to an old Intel i5 / El Capitan computer.

I USED BOTH TO BE SURE ONE OF THEM WORKS OR…

does the search work if you put TA.Text as a string property? (for a test)

You mean storing the text from the file into a string and search that string ? It’s an idea.

No, It change nothing.

There is a bug here, one we saw some days ago. I wanted to know, while I have an M1, etc. if this is also the case there.

What I do not understand yet, is why I never saw it before. Copy / Paste file names from the Finder into a Xojo application is something I do everyday since… I cannot remember.

I even added a feature for when I run Windows to get the file names from windows because it is not possible to do that with Select All Items / Copy / Paste with the Explorer (until last year).

[quote=“Emile_Schwarz, post:1, topic:62775”]

I USED BOTH TO BE SURE ONE OF THEM WORKS OR…

are you sure? in your example you use InStrB and only message box is InStr

If InStrB(TA.Text, TF_Search.Text) > 0 Then
  MsgBox "InStr() found it !"
End If

if the match fail i would put both into memory blocks and compare this 2.

Sorry… Reading the original post, you understand what I wanted to do (and failed). After all, my brain must be elsewhere (awaiting for coffee ?) !

That is where Copy / Paste allows me to fail !

The test (once mlodified) failed too.

You can do it by yourself, and use Aldi SĂĽed for example ! :wink:

I will try (once back home) to upload the example in a web server.

1 Like

the problem is here.

DefineEncoding(TF_Search.Text, Encodings.UTF8)

please try beta and make a feedback.
System.DebugLog is your friend :wink:

without DefineEncoding and only InStr works

input aaa and after DefineEncoding a

cut to one char if search go through DefineEncoding

Project and sample text here:

see my answer before :slight_smile:

Thank you Markus for trying to help.

I will read this post in a minute, but have to add something:

I started from a if compare:

If f.Name = "vallée.txt" Then
// Do something
Else
System.DebugLog "The if test failed."
End If

So talking about InStr / InStrB or strcomp or whatever is irrelevant, but I tested that just to be sure (and with latest Xojo, OS and hardware).

Now, I will read the post.

Nota: for testing (and in that case), using MsgBox or System.DebugLog is irrelevant (we do not care); the former was faster. I was in my car, so…

? If you meant Xojo 2021 beta… no way. My license expired years ago.

You may have skipped the source of the data n the text file: files names copied from the Finder and pasted in TextEdit, then saved as .txt (check my project). Typing text works fine. As well as Copy the search text from the loaded data.

Hard to follow… that is why I wanted to share the project wth the text file; but I do not had name/password to upload my zip.

that does not work, source is empty

TA.Text = t.ReadAll
Source = t.ReadAll

try

Source = t.ReadAll
TA.Text = Source

and then vallée is not vallée, in debugger it have different byte count.
it looks equal but it is not.

composited characters???

Absolutely (for composite) that is the culprit.

That is why I set the Encoding to UTF8 n both cases, use the most recent software / hardware.

For source = empty: I do not recall (probably bad testing here… I needed my coffee ?), but setting the Read Position to 0 (or 1) before the second Read will solve that.

Now, I got days ago a problem with a character at sort time: standard space (32) and non breaking space (160): looks similar, have the same amount of bytes (1) and tooks time until I realize that is the other space.
What I do not discover is how I could have placed a nbsp character (Option-Space in my French Keyboard) in file names (located in the first 15 or so characters of the file name…).

No, voodoo is not involved here (…)

1 Like

Ashampoo_Snap_Sonntag, 18. April 2021_9_22_2_001_

you can make composited character visible if you mark them shift+cursor right in ide code editor.

thailand using also composited characters.
you need hit 3 or more backspace until one char disappear.

I am quite sure you can get the probem with your German OS.

I do not know about Windows, sorry.

Remember:
I do not typed anything on purpose to get troubles ;). I only typed text to name files; these names holds what you called composite character, but they came from my keyboard. So, if you create a Folder you call it “Aldi-Süed.de“, then read its name and compare t vs “Adi-Nord.de” you will fall into troubles.
And this is certainly the case for nearly each and every European names “España” for Spanish, etc. for Italian, Dutch, Dannish, Svedish, …

i had customer calls and search them in database and not found them because variant spelling.
what i heard was written with other notation. ups. both in name and street^^
or i forgot to clear other filters…

ei = ay
i = ie
ä = ae
…

i think the only way to find it is a multiple search. or a replace before.