DBCS & _MBCS issues trying to force micron character "µ"

Hi to all, esp anyone that can guide me!!

We have an application (very 'long in the tooth', VC++ 6) that has been see to show odd characters on Japanese Windows installations.

The route of the problem is a CStatic derived class that is used to display text on a tool bar. For example:

CsZ.Format("Z:%6.1fµm", Val);
...
m_ZPosVal.SetWindowText(CsZ);

where CsZ is a cstring and m_ZPosVal is the CStatic derived class, and the text string ("") is the the position in microns of a pointer.

Unfortunately, the micron symbol is converted to kanji (or similar) on Japanese Windows.

My very simple task is to embed or force the "µ" symbol to remain as-is despite language settings.

Our application is built with _MBCS defined - so that SHOULD handle single and double characters in a text string (as I understand). However, I can find no way to force this case. I have tried things like:

CsY.Format("Y:%6.0f\xB5m", Val);
&
CsY.Format("Y:%6.0f\x00B5m", Val);

as well as various _mbs functions to force the case prior to putting into cstring...

Unfortunately, unicode is far to big a change (weeks & weeks) for such a small (but important!) tweak as this.

Surely there is an easy method that I am missing somewhere!? Does anyone know an answer?

Much appreciation for any help.
http://www.rikai.com/library/kanjitables/kanji_codes.sjis.shtml

83 be | α β γ δ ε ζ η θ ι κ λ μ ν ξ ο 83 ce | π ρ σ τ υ φ χ ψ ω

Shift-JIS defines Greek characters around here. (0xB5 is the Unicode code point.)

Of course what you really want is Microsoft Code Page 932 reference. In case MS did something different ;)

Anyway what you want to know is this. To make it all independent of the actual Windows language (or locale rather), you could define a Unicode string with Unicode μ (0x00B5) and at runtime use wcstombs to get the correct character for the language that is in effect. (At a guess).

(Strangely enough B5 is short for Big5, Chinese code page...)
Last edited on
Actually, if the users don't actually need Japanese for your app, you can force the application to think it's running on a European/US version of Windows without affection other applications.

Under Windows XP I used Applocale (free from MS). Unfortunately this isn't officially available for Vista/Se7en.

http://en.wikipedia.org/wiki/AppLocale
Last edited on
Hi Choisum,

Thanks for the reply & sorry for the delay. I'll try your suggestions and report back my findings. As work's gone silly at the moment - this may be a while ;-)

Seriously though, thanks for your input! Much appreciated!!!!! :-D

Dan.
You're welcome. I'm interested in this for my own reasons too!

Here's a test progam which converts 0x00b5 into 0x03ca.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include<stdlib.h>
using namespace std;
int main()
{
	char sz[20];

	// Unicode for mu
	wchar_t wsz[20] = L"\x00b5";

	// Set Japanese code page
	// May not be necessary for MBCS Windows GUI program
	setlocale(LC_ALL, ".932");

	int i = wcstombs(sz, wsz, 20);

	cout << i << endl;
	cout << hex << int(sz[0]) << endl;
	cout << hex << int(sz[1]) << endl;
}

Last edited on
Topic archived. No new replies allowed.