wxFileConfig的问题

31 views
Skip to first unread message

xunj...@gmail.com

unread,
Jun 21, 2006, 11:35:40 PM6/21/06
to wxLife
wxWidgets中的wxFileConfig用于将数据以key=value的形式(或者说就是Windows中的ini文件的格式)保存到文件中。测试发现,在ANSI版本中如果key部分输入中文会出现错误。
---------------------------------------------------
#include <wx/wx.h>
#include <wx/wfstream.h>
#include <wx/fileconf.h>

int main( void )
{
wxFileInputStream fis( wxT("test.ini") );
if ( ! fis.Ok() )
{
printf( "ERROR: Open ini file failure!" );
return -1;
}

wxFileConfig fc( fis );
fc.SetPath( wxT("/server") );

wxString entry;
long index;
wxString value;
bool result = fc.GetFirstEntry( entry, index );
while ( result )
{
fc.Read( entry, &value );
printf( "%ld: %s=%s\r\n", index, entry.c_str(), value.c_str() );
result = fc.GetNextEntry( entry, index );
}

return 0;
}
---------------------------------------------------
通过这些代码可以发现wxFileConfig将数据读入后都处理成什么结果了。

Reply all
Reply to author
Forward
0 new messages