Click here to Skip to main content
15,898,035 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralPerformance Testing Pin
LighthouseJ2-Feb-05 12:56
LighthouseJ2-Feb-05 12:56 
GeneralRe: Performance Testing Pin
Bob Ciora2-Feb-05 13:28
Bob Ciora2-Feb-05 13:28 
GeneralRe: Performance Testing Pin
LighthouseJ2-Feb-05 13:30
LighthouseJ2-Feb-05 13:30 
GeneralRe: Performance Testing Pin
Bob Ciora2-Feb-05 13:44
Bob Ciora2-Feb-05 13:44 
GeneralLink in RichEditCtrl Pin
merkit2-Feb-05 12:48
merkit2-Feb-05 12:48 
GeneralPrivate inheritance question Pin
marinme2-Feb-05 12:03
marinme2-Feb-05 12:03 
GeneralRe: Private inheritance question Pin
Bob Ciora2-Feb-05 12:48
Bob Ciora2-Feb-05 12:48 
GeneralConverting DBCS to Unicode Pin
RYU^^2-Feb-05 11:37
RYU^^2-Feb-05 11:37 
Hi GURU,

I am getting double byte value from AS400 in EBCDIC with the values 0x43 and 0xA4. These values must be converted to be 0x83 and 0x7D.

The reason is that both values (0x43 and 0xA4) will made a single character which is represented by PC code as 0x83 and 0x7D.

Please look at the scheme below:
--------------------------------------------------------------------
|               EBCDIC               |            ASCII            |
--------------------------------------------------------------------
|               0x43                 |             0xA3            |
|               0xA4                 |             0xCF            |
|            0x43 and 0xA4           |        0x83 and 0x7D        |
--------------------------------------------------------------------


As you can see from the scheme above, if I do single byte conversion, 0x43 will becomes 0xA3 and 0xA4 will becomes 0xCF. However, if double byte conversion, the value 0x43 0xA4 will become 0x83 and 0x7D.

The problem I have is when I am using MultiByteToWideChar(), it is intepreted 0x83 as single value and 0x7D as another value. Therefore the result of the conversion is 0xA3 and 0xCF. My question is, how can I made MultiByteToWideChar() knows that both 0x43 and 0xA4 are double byte values that made 1 single character?

This is the code that I did:
<br />
const int IBMCodePage = 20290;	//IBM EBCDIC Japanese code page<br />
const int PCCodePage = 932;	//PC Japanese code page<br />
<br />
BYTE byteEBCDIC[2] = {0x43, 0xA4};<br />
BYTE byteASCII[2];<br />
wchar_t wchBytes[1024];<br />
DWORD dwSize;<br />
<br />
dwSize= MultiByteToWideChar(IBMCodePage , MB_PRECOMPOSED, (const char*)byteEBCDIC, 2, wchBytes, 1024);<br />
dwSize= WideCharToMultiByte(PCCodePage , WC_COMPOSITECHECK | WC_SEPCHARS, wchBytes, dwSize, (char*)byteASCII, 2, NULL, NULL);<br />


Thanks for any helps in advance...

Cheers... Smile | :)
GeneralRe: Converting DBCS to Unicode Pin
Anthony_Yio2-Feb-05 23:26
Anthony_Yio2-Feb-05 23:26 
GeneralRe: Converting DBCS to Unicode Pin
RYU^^3-Feb-05 11:26
RYU^^3-Feb-05 11:26 
GeneralRe: Converting DBCS to Unicode Pin
Anthony_Yio3-Feb-05 15:40
Anthony_Yio3-Feb-05 15:40 
GeneralRe: Converting DBCS to Unicode Pin
RYU^^3-Feb-05 17:34
RYU^^3-Feb-05 17:34 
GeneralRe: Converting DBCS to Unicode Pin
Anthony_Yio3-Feb-05 19:29
Anthony_Yio3-Feb-05 19:29 
GeneralRe: Converting DBCS to Unicode Pin
RYU^^3-Feb-05 19:50
RYU^^3-Feb-05 19:50 
GeneralClipboard functions Pin
TeresaPrice2-Feb-05 7:44
TeresaPrice2-Feb-05 7:44 
GeneralRe: Clipboard functions Pin
BlackDice2-Feb-05 10:43
BlackDice2-Feb-05 10:43 
GeneralShifting Text in Visual C++ Text Editor Pin
K. Shaffer2-Feb-05 6:13
K. Shaffer2-Feb-05 6:13 
GeneralRe: Shifting Text in Visual C++ Text Editor Pin
bluerider2-Feb-05 6:35
bluerider2-Feb-05 6:35 
GeneralRe: Shifting Text in Visual C++ Text Editor Pin
K. Shaffer2-Feb-05 7:30
K. Shaffer2-Feb-05 7:30 
GeneralRe: Shifting Text in Visual C++ Text Editor Pin
alex.barylski2-Feb-05 11:27
alex.barylski2-Feb-05 11:27 
GeneralRe: Shifting Text in Visual C++ Text Editor Pin
Ryan Binns2-Feb-05 17:30
Ryan Binns2-Feb-05 17:30 
GeneralRe: Shifting Text in Visual C++ Text Editor Pin
alex.barylski6-Feb-05 11:10
alex.barylski6-Feb-05 11:10 
GeneralWanted: VS colorer add-in sources Pin
yuri_g2-Feb-05 4:41
yuri_g2-Feb-05 4:41 
GeneralRe: Wanted: VS colorer add-in sources Pin
S Douglas2-Feb-05 19:09
professionalS Douglas2-Feb-05 19:09 
GeneralBinary Files Pin
mcsherry2-Feb-05 3:54
mcsherry2-Feb-05 3:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.