User forums > Using Code::Blocks
ThreadSearch can't open the utf8 files!
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
--- Code: ---TextFile.Open(filePath, wxConvFile)
--- End code ---
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
--- Code: ---TextFile.Open(filePath, wxConvFile)
--- End code ---
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.
--- End quote ---
You should use C::B's built-in mechanism to read unicode file. Please follow the following steps-
--- Code: ---#include "encodingdetector.h"
....
wxString fooFileContent;
EncodingDetector fooFile(_T("foo.cpp"));
if (fooFile.IsOK())
{
fooFileContent = fooFile.GetWxStr();
}
--- End code ---
Encoding detection and conversion will be done by C::B automatically. :)
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
Navigation
[0] Message Index
[#] Next page
Go to full version