Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29244 Discussions

characters on a Japanese window system

steve_konarski
Beginner
589 Views

I am running a program to output the degree sign. The degree sign on the English and Japanese set up is 176 on the character map. The relavent parts of the code are

-----------------------------------------------------

INTEGER*2 IN

INTEGER J

.

.

IN=176

J=MBCONVERTUNICODETOMB(IN,C2)
.

WRITE(6,*)C2(1:J)

---------------------------------------------------

ON running the program J has a value of 2 (bytes) and when opened in textpad the entries are81 and 8B and on subsequent output gives ?? on a drawing.

How can i get the degree suymbol ( and other chatacters in the character map range 127-255) to be correctly output on a Japanese window system

0 Kudos
2 Replies
Jugoslav_Dujic
Valued Contributor II
589 Views
Sorry, it's Japanese to me Smiley with tongue out [:-P]. I just wanted to post a link to this comprehensive (if oldish) text. For what I know, the additional layer of problem is that the console window uses its own (OEM) code page, and there are functions OemToChar and OemToCharBuff which do... something. Sorry, I don't know the details.

Given the headaches of MBCS, I'd say your best bet would be to use Unicode all around (although it would probably also require extensive use of APIs such as WriteConsoleOutputCharacterW rather than plain WRITEs).
0 Kudos
Les_Neilson
Valued Contributor II
589 Views

You may need to check which font you are using for the output and that it supports the character set you require. I notice you mention "drawing" Do you mean hard copy (paper) or a drawing in a window? Are you developing ON a Japanese system or FOR a Japanese system?

For example. We aredeveloping on English Windows XP for non-English users. The following is some (cut down) code used to take a simple ascii text string and convert it to Unicode.

!-----------------------------------------------------------------------
subroutine schara(string,iclen)
implicit none

integer :: ICLEN
character(*) :: STRING

integer(2), DIMENSION (256) :: utext

INTERFACE TO SUBROUTINE mbcs2unicode [C,ALIAS:'_mbcs2unicode'] (d,e,f)
integer*4 :: d
integer*4 :: e
integer*4 :: f
END


t_len = iclen
call mbcs2unicode(loc(string), loc(t_len), loc(utext))

end subroutine schara

and the c file : mbcs2unicode.c

#include
#include
#include

void mbcs2unicode (char *lpszA, int *iLen, short *utext)
{

int i;
TCHAR s_lcid[6];
WCHAR lpszW[256];
LCID LCid,CPage;

// Get Current User Locale ID and translate into a Code Page
LCid = GetUserDefaultLCID();

// Default code page = English
CPage = 1252;

i = GetLocaleInfo(LCid,LOCALE_IDEFAULTANSICODEPAGE, s_lcid, 6);

// Check we got a code page
if (i != 0) {
CPage = _ttoi(s_lcid);
if (CPage == 0) {CPage = 1252;}
}

*iLen = MultiByteToWideChar(CPage, 0, lpszA, *iLen, lpszW, 256);

for (i=0; i<*iLen; i++) {
utext = lpszW;

}

}

Hope this helps

Les

0 Kudos
Reply