News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

ThreadSearch can't open the utf8 files!

Started by nanyu, August 28, 2008, 04:49:49 AM

Previous topic - Next topic

nanyu

1. windows xp.
2. codeblock svn 5195 (maybe all version)
3. save the a cpp files to two copies,  one encode by ansi, named a.cpp;
     the other is  utf8 (the file begin with  "0xEFBB"), named a_utf8.cpp;
4. check the "threadsearch" option item: "show error message if file cannot be opened."
5. press "search" button...
6. a message box popup.. "Fail to open c:\a_utf8.cpp" ..

anyone help me? thanks!

dje

Hi !

The implementation used to open file for searching is
TextFile.Open(filePath, wxConvFile)
Solution was provided by Tiwag in this thread and is for now the best I've found.
Problem is that I don't know any way to find file encoding.

Did you try to set the "default encoding when opening file" to UTF-8 in editor settings ?
With this, I have no problem searching ASCII and UTF-8 files.

Dje

Biplab

Quote from: dje on August 31, 2008, 10:21:22 AM
The implementation used to open file for searching is
TextFile.Open(filePath, wxConvFile)
Solution was provided by Tiwag in this thread and is for now the best I've found.
Problem is that I don't know any way to find file encoding.

You should use C::B's built-in mechanism to read unicode file. Please follow the following steps-

#include "encodingdetector.h"

....


wxString fooFileContent;
EncodingDetector fooFile(_T("foo.cpp"));
if (fooFile.IsOK())
{
    fooFileContent = fooFile.GetWxStr();
}


Encoding detection and conversion will be done by C::B automatically. :)
Be a part of the solution, not a part of the problem.

nanyu

to dje:thank you!
i had set the "default encoding when opening file" to UTF-8 in editor settings.
i am puzzled now. the files encoding utf-8, some of them can be openned by ThreadSearch, but  some of them is not.

dje

Hi !

Biplab, I don' forget your advice, but I'm a quite busy right now and it requires a little work, as just replacing file opening with your snippet is not sufficient.

nanyu, do you know when it works or not ?
Does it depend on encoding ? I had already problems when files used different end of lines chars (mixing of editor gave such wonderful results).
Could you send a working and not working one ?

Dje

nanyu

Please Unzip the Attach file.

ThreadSearch do work well with "ok.txt", but fail to open the "fail.txt".
(please open the txt file for more information)

In my CodeBlocks, i set the "utf-8" encoding.

---
windowx XP (Chinese).



[attachment deleted by admin]

dje

Hi Nanyu !

Thanks for files, I'll check tonight (at french time ;))

Dje

dje

Hi nanyu,

I tried on my French XP home edition SP3 and it works as expected.
I'll try to follow Biplab advice this WE but I won't be able to do other tests than non regression.

I joined a working snapshot and my default.conf if you want to try it.

Dje

[attachment deleted by admin]