Question

I want to know the location of 'BOM' character in the file and how can i view this character. It will be helpful if somebody explain what is BOM character. I want to do is that i am having ANSI file and i want to convert it into UTF-8 encoding \ how can i do that?

Thanks in advance

Was it helpful?

Solution

" I want to know the location of 'BOM' character in the file

the BOM is at the beginning of the file.

why didn't you google it or look it up in wikipedia.

" how can i view this character

ordinarily you can't, but in some situations it's displayed.

" It will be helpful if somebody explain what is BOM character

BOM was originally a byte order mark, used to make it easy to determine the endianness of UTF-16 or UTF-32 encoded text. in Windows it's used also to identify UTF-8 encoded files as such, and in particular the visual c++ compiler will misidentify the encoding if there is no BOM. the wikipedia article about BOM is unfortunately skewed towards a Unix-land fan boys point of view where UTF-8 files should be incompatible1 with common requirement in Windows (it helps to consider that Microsoft was a founding member of the Unicode consortium, thus there's nothing in the Unicode standard that's contrary to the convention in Windows).

" I want to do is that i am having ANSI file and i want to convert it into UTF-8 encoding \ how can i do that

to convert accurately you need to know the exact encoding used for the file. note that "windows ansi" is a set of possible encodings, where the windows ansi on a given Windows installation is the codepage reported by the GetACP API functions. given the knowledge of the encoding you can use either the Windows API's MultiByteToWideChar, or the C library's mbcstowcs, or the C++11 C++ library's codecvt.


1) of old the g++ compiler choked on BOM in UTF-8 source code, the opposite of visual c++ which requires a BOM. happily modern version of g++ accepts the BOM. as it is required to do by the standards.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top