23 #define strcasecmp _stricmp 41 static const unsigned char utf8table[64];
62 cerr <<
"Warning: UTF-BOM doesn't match encoding setting, but given encoding forced" <<
endl;
78 inputfile.
read(reinterpret_cast<char*>(&
buffer),4);
88 #ifdef DISPLAY_DETECTED_UNICODE 99 #ifdef DISPLAY_DETECTED_UNICODE 100 cerr <<
"UTF-16BE BOM found" <<
endl;
112 cerr <<
"UTF Error: ambiguous BOM UTF-16 or UTF-32; assume UTF-32" <<
endl;
119 #ifdef DISPLAY_DETECTED_UNICODE 120 cerr <<
"UTF-16LE BOM found" <<
endl;
132 #ifdef DISPLAY_DETECTED_UNICODE 133 cerr <<
"UTF-32BE BOM found" <<
endl;
149 inputfile.
read(reinterpret_cast<char*>(&
c),1);
150 return inputfile.
gcount();
161 w =
c[0] | (
c[1] << 8);
163 w =
c[1] | (
c[0] << 8);
169 for (
int i=0;
i<4;
i++)
173 d =
c[0] | (
c[1] << 8) | (
c[2] << 16) | (
c[3] << 24);
175 d =
c[3] | (
c[2] << 8) | (
c[1] << 16) | (
c[0] << 24);
186 unsigned char c, tmp;
195 if ((tmp & 0xc0) != 0xc0)
197 cerr <<
"UTF-8 Error: invalid data byte" <<
endl;
200 unsigned char i = utf8table[tmp & 0x3f];
219 if ((
w & 0xfc00) == 0xd800)
221 if (getWord(
w2) != 2)
223 if ((
w2 & 0xfc00) != 0xdc00)
225 cerr <<
"UTF-16 Error: invalid low surrogate" <<
endl;
228 return (((
w & 0x3ff) + 0x40) << 10) | (
w2 & 0x3ff);
233 if (getDWord(
ret) != 4)
241 unsigned char buffer[2] = { 0xff, 0xfe };
245 outputfile.
write(reinterpret_cast<char*>(&
buffer), 2);
248 wchar_t c = get_wchar_t();
250 while (!inputfile.
eof())
254 outputfile.
write(reinterpret_cast<char*>(&
buffer),2);
268 1, 9, 17, 25, 33, 41, 49, 57, 65, 73, 81, 89, 97, 105, 113, 121,
269 129, 137, 145, 153, 161, 169, 177, 185, 193, 201, 209, 217, 225, 233, 241, 249,
270 2, 10, 18, 26, 34, 42, 50, 58, 66, 74, 82, 90, 98, 106, 114, 122,
271 3, 11, 19, 27, 35, 43, 51, 59, 4, 12, 20, 28, 5, 13, 6, 7
281 cout <<
"usage: " <<
argv[0] <<
" inputfile outputfile" <<
endl;
299 cerr <<
"Couldn't open input file." <<
endl;
302 cerr <<
"Couldn't open output file." <<
endl;
GLubyte GLubyte GLubyte GLubyte w
static const unsigned char utf8table[64]
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
std::streamsize getByte(unsigned char &c)
_Self & write(const char_type *__s, streamsize __n)
_STLP_DECLSPEC _Stl_aligned_buffer< ostream > cerr
_STLP_MOVE_TO_STD_NAMESPACE void fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
std::streamsize getWord(unsigned short &w)
const GLuint GLenum const GLvoid * binary
utf_converter(string ifname, string ofname, bom_types ofbom=bom, enc_types enc=detect)
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble GLdouble w2
void open(const char *__s, ios_base::openmode __mod=ios_base::in|ios_base::out)
_Self & read(char_type *__s, streamsize __n)
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)
static BYTE decode(char c)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
streamsize gcount() const
int main(int argc, char *argv[])
std::streamsize getDWord(wchar_t &d)
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)