wxString SpringUnitSync::GetTextfileAsString( const wxString& modname, const wxString& file_path ) { susynclib().SetCurrentMod( modname ); int ini = susynclib().OpenFileVFS ( file_path ); if ( !ini ) return wxEmptyString; int FileSize = susynclib().FileSizeVFS(ini); if (FileSize == 0) { susynclib().CloseFileVFS(ini); return wxEmptyString; } uninitialized_array<char> FileContent(FileSize); susynclib().ReadFileVFS(ini, FileContent, FileSize); return wxString( FileContent, wxConvAuto(), size_t( FileSize ) ); }
wxString convert(char* buff, const int len) { wxString ret = wxString(buff, wxConvUTF8, len ); if ( !ret.IsEmpty() ) { return ret; } ret = wxString(buff, wxConvLibc, len); if (!ret.empty()) { return ret; } ret = wxString(buff, wxConvLocal, len ); if ( !ret.IsEmpty() ) { return ret; } ret = wxString(buff, wxConvISO8859_1, len ); if (!ret.empty()) { return ret; } ret = wxString(buff, wxConvAuto(), len ); if (!ret.empty()) { return ret; } std::string tmp(buff, len); wxLogDebug(_T("Error: invalid charset, replacing invalid chars: '%s'"), TowxString(tmp).c_str()); //worst case, couldn't convert, replace unknown chars! for(int i=0; i<len; i++) { if ((buff[i] < '!') || (buff[i] > '~')){ buff[i] = '_'; } } ret = wxString(buff, wxConvUTF8, len ); if (!ret.empty()) { return ret; } wxLogDebug(_T("Fatal Error: couldn't convert: '%s' in socket.receive()"), TowxString(tmp).c_str()); return wxEmptyString; }
// read symbol table void Database::loadSymbols(wxInputStream &file) { wxTextInputStream str(file, wxT(" \t"), wxConvAuto(wxFONTENCODING_UTF8)); int c = 0; while(!file.Eof()) { wxString line = str.ReadLine(); if (line.IsEmpty()) break; std::wistringstream stream(line.c_str().AsWChar()); Symbol *sym = new Symbol; stream >> sym->id; ::readQuote(stream, sym->module); ::readQuote(stream, sym->procname); ::readQuote(stream, sym->sourcefile); stream >> sym->sourceline; sym->isCollapseFunction = osFunctions.Contains(sym->procname.c_str()); sym->isCollapseModule = osModules.Contains(sym->module.c_str()); symbols[sym->id] = sym; } }
void FileViewer::ShowReference(const wxString& ref) { const wxFileName filename = GetFilename(ref); wxFFile file; wxString data; if ( !filename.IsFileReadable() || !file.Open(filename.GetFullPath()) || !file.ReadAll(&data, wxConvAuto()) ) { wxLogError(_("Error opening file %s!"), filename.GetFullPath().c_str()); return; } m_current = ref; // support GNOME's xml2po's extension to references in the form of // filename:line(xml_node): wxString linenumStr = ref.AfterLast(_T(':')).BeforeFirst(_T('(')); long linenum; if (!linenumStr.ToLong(&linenum)) linenum = 0; m_text->SetReadOnly(false); m_text->SetValue(data); m_text->SetReadOnly(true); m_text->MarkerDeleteAll(1); m_text->MarkerAdd((int)linenum - 1, 1); // Center the highlighted line: int lineHeight = m_text->TextHeight((int)linenum); int linesInWnd = m_text->GetSize().y / lineHeight; m_text->ScrollToLine(wxMax(0, (int)linenum - linesInWnd/2)); }
void ConvAutoTestCase::TestFirstChar(const char *src, wchar_t wch, size_t len) { wxWCharBuffer wbuf = wxConvAuto().cMB2WC(src, len, NULL); CPPUNIT_ASSERT( wbuf ); CPPUNIT_ASSERT_EQUAL( wch, *wbuf ); }
void ConvAutoTestCase::Empty() { CPPUNIT_ASSERT( !wxConvAuto().cMB2WC("") ); }