Alright I think I’m just lost here but maybe someone can straighten me out:
I have the following Korean Character:
KSC5601 0xD3CB (Looks like a box with a 7 and A above it) (Sorry about
the description)
When I look this up I find that:
KSC5601 0xD3CB = Unicode 0x6793 = U+6793
I’ve then looked up the UTF-8 FAQ
http://www.cl.cam.ac.uk/~mgk25/unicode.html
This states that codes greater than U+007F are encoded as a sequence of
several bytes, etc…
But when I use PtTranslateToUTF() on 0xD3CB I get as output 0x6C9372
This looks like Unicode and Not UTF-8. Is this correct or is the
documentation saying UTF-8 really Unicode?
Here is a a callback that I have on a button simple app builder program to
demonstrate.
Thanks for any info people can give
Jeff
–
Jeffrey B. Holtz
Software Engineering
Electro Scientific Industries, Inc.
Ph: 734-332-7054
Fax: 734-332-7077
email: holtzj@esi.com
/* Callback /
/ AppBuilder Photon Code Lib /
/ Version 2.01 */
/* Standard headers */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
/* Local headers */
#include “ablibs.h”
#include “abimport.h”
#include “proto.h”
// The following equates to:
// KSC5601 - 0xD3CB
// Unicode - 0x6C93
char * pcKSC5601 = “\xD3\xCB”;
char * pcUnicode = “\x6C\x93”;
#define BUFFER_SIZE 256
int
ButtonPressed( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t
*cbinfo )
{
struct PxTransCtrl * trans = NULL;
FontDetails * fontDetails = NULL;
char * pmbUTF8 = NULL;
int nConsumed = 0, nProduced = 0;
int nTranslateCode = 0;
int lenKSC5601 = 0;
int lenUnicode = 0;
int nNumFonts = 0;
int nfont = 0;
int nloop = 0;
uchar_t fontName[MAX_FONT_TAG];
memset(fontName,0x00,sizeof(fontName));
/* eliminate ‘unreferenced’ warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;
trans = PxTranslateSet(NULL,“EUC-KR”);
if (trans == NULL)
{
printf(“Unknown translation State\n”);
return (Pt_CONTINUE);
}
if (pmbUTF8 == NULL)
pmbUTF8 = calloc(BUFFER_SIZE, sizeof(char));
memset(pmbUTF8,0x00,sizeof(BUFFER_SIZE));
printf("\nTranslating pcKSC5601 To UTF-8\n");
lenKSC5601 = strlen(pcKSC5601);
printf("pcKSC5601 = ");
for (nloop=0; nloop<lenKSC5601; nloop=nloop+2)
{
printf(“0x%02X%02X “,
(unsigned char)pcKSC5601[nloop],
(unsigned char)pcKSC5601[nloop+1]);
}
printf(”\n”);
nTranslateCode = PxTranslateToUTF(trans, // Translation Code
pcKSC5601, // Source String to Convert
lenKSC5601, // Source String Size
&nConsumed, // Number of Source Bytes Consumed
pmbUTF8, // UTF-8 Destination buffer
BUFFER_SIZE, // Max UTF-8 Destination buffer
&nProduced); // Number of Destination Bytes Produced
if (nTranslateCode == -1)
{
printf(“Could Not Translate to EUC-KR\n”);
return (Pt_CONTINUE);
}
printf(“Source Consumed = %d\n”,nConsumed);
printf(“Destination Produced = %d\n”,nProduced);
printf("\npmbUTF8 = 0x");
for (nloop=0; nloop <nProduced; nloop=nloop+1)
printf("%02X",(unsigned char)pcUnicode[nloop]);
printf("\n");
if (PfGenerateFontName(“Bitstream SB Gothic KR Uni”, PF_STYLE_BOLD, 24,
fontName) == NULL)
printf(“Can’t create FontName4\n”);
PtMessageBox(widget,NULL,pmbUTF8,fontName,“Press ME”);
return( Pt_CONTINUE );
}