Show page source of Technical details #41435

'''Source code file format''': These are currently in Unicode UTF-8 without BOM.  The BOM reportedly causes problems with many programs, particularly on non-Windows platforms.  Unfortunately compiler warnings are given - but the text is actually saved without problems (fingers crossed).  

{{{
warning C4819: The file contains a character that cannot be represented in the current code page (932). Save the file in Unicode format to prevent data loss
}}}

Note that windows notepad automatically adds back in the BOM when you save files edited with it.

'''Pre-Windows XP:''' I do not intend to support Windows 95/98/Me.  The API of those operating systems does not support Unicode well and there are probably not enough people still using them to be worth the effort.

'''Other Windows compilers:''' VC++ Express Edition is a free download so I do not intend to work to support other compilers in the foreseeable future.

'''_TCHAR and other macros''' These macros are Microsoft specific and are used to switch between Unicode and plain ASCII handling depending on compiler settings.  My current plan is to alter the macros so they switch between Windows and Linux compatible code (or they may just end up search and replaced into something else if necessary ;-).

'''Wide-text considerations:''' 

1. _countof(x) not sizeof(x).  Characters in a wide-text string take up two bytes not one.  So "HELLO" is a string six characters long (including '\0') but 12 bytes long.  sizeof(x) returns the number of bytes of x which, coincidentally, is the number of characters for narrow-text. _countof(x) is a macro that returns the number of elements in an array.  Usually _countof will be correct and sizeof cause problems.

2. Similarly you need to watch out for functions that work on bytes, not number of characters (array elements). You may need to multiply by character (array element) size. e.g. memcpy(tagbuffer, tag, taglen'' * sizeof(_TCHAR)'');

3. Japanese text characters are ''literally'' wide.  That is they (depending on font) take up twice the width on the screen as normal English characters take.  This shows up in, for example, the splash screen.  Other Japanese *band variant games deal with this properly (e.g. XAngband) so I will be checking how they do it in their code.

4. Unicode (UTF-16) text files are not displayed correctly in the web-based Subversion repository browser.  This helped me to decide to switch back to UTF-8 now that I've got the code for reading UTF-8 text files working again.  If you want to know why UTF-16 can't be shown in the Subversion browser see [http://viewvc.tigris.org/issues/show_bug.cgi?id=25 Display unicode files correctly]).