📄 a_iconv.cpp
字号:
/* Read text file as in BIG5 encoding, convert to UTF8 and write to cout Build: make a_iconv*/#include "../src/wyregfile.h"#include "../src/wy_uty.h"#include "../src/wyiconv.h"static const WyCSeg IFName="../src/mid_ord.big5";int main(void) throw()try { WyRegFile infile(IFName,O_RDONLY); WyStr rbuf,obuf; WyRet r; // Get file size and set capacity of rbuf { WyFileStat stt; if((r=infile.stat(stt))!=Ok) { WY_THROW(r); } if((r=rbuf._reserve(stt.sf_size()))!=Ok) { WY_THROW(r); } } // Read the whole file into rbuf infile >> rbuf; // Convert rbuf as in BIG5 encoding to UTF8 encoding stored into obuf { WyIConv cvrt("UTF8","BIG5"); size_t n_rev; WyCSeg rseg( rbuf.cseg() ); if((r=cvrt.iconv(rseg,obuf,n_rev))!=Ok) { WY_THROW(r); } } // Write obuf to standard output Wy::cout << obuf; return(0);}catch(const WyRet& e) { if(e!=Ok) { Wy::cerr << Wy::wrd(e) << '\n'; } return e->c_repcode();}catch(...) { Wy::cerr << "main caught(...)\n"; return(-1);};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -