473,320 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Multibyte Character to WideChar

1,059 1GB
Hello Everybody,

I am having a problem with converting value from multibyte to widechar

input variable is data
output variable is data_m
Expand|Select|Wrap|Line Numbers
  1. #define CP_SHIFT_JIS 932
  2.  
  3.  
  4. wchar_t *data_m;
  5.     data_m=(wchar_t*)malloc(sizeof(wchar_t)*1024);
  6.     memset(data_m, 0, sizeof(wchar_t)*1024);
  7.     MultiByteToWideChar(CP_SHIFT_JIS,0,data,-1,data_m,0);
  8.  
Sample Input:
Expand|Select|Wrap|Line Numbers
  1. HTTP/1.1 200 OK
  2. Date: Wed, 13 Jan 2010 07:34:33 GMT
  3. Server: Apache/2.2.3 (Win32) PHP/5.2.0
  4. X-Powered-By: PHP/5.2.0
  5. Content-Length: 10
  6. Connection: close
  7. Content-Type: text/html
  8.  
  9. Ž„<br>“c’¬
  10.  
i was expecting output from the above code and value is

Expand|Select|Wrap|Line Numbers
  1. HTTP/1.1 200 OK
  2. Date: Wed, 13 Jan 2010 07:34:33 GMT
  3. Server: Apache/2.2.3 (Win32) PHP/5.2.0
  4. X-Powered-By: PHP/5.2.0
  5. Content-Length: 10
  6. Connection: close
  7. Content-Type: text/html
  8.  
  9. 私<br>田町
  10.  
Let me know what am I missing....

Help is always appreciated.

regards,
Johny
Jan 12 '10 #1
1 4116
johny10151981
1,059 1GB
Hello,
I solved the problem reading from a Japanese site. The code should be something like that
Expand|Select|Wrap|Line Numbers
  1.     wchar_t *data_m;
  2.  
  3.     int unilen = MultiByteToWideChar(CP_SHIFT_JIS, 0, data, -1, NULL, 0);
  4.   if (unilen <= 0) {
  5.     MessageBox(ghwnd,L"Error: charconv_win32: conversion error?\n",L"Error",MB_OK);
  6.  
  7.   }
  8.   if (unilen > UNICODE_BUFFER_SIZE) {
  9.     MessageBox(ghwnd,L"Error: charconv_win32: unicode buffer size Exited",L"Error",MB_OK);
  10.   }
  11.   /* convert source string to unicode */
  12.     data_m=(wchar_t*)malloc(unilen);
  13.     MultiByteToWideChar(CP_SHIFT_JIS, 0, data, -1, data_m, unilen);
  14.  
regard,
johny
Jan 12 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: lian | last post by:
Hi all, I want to write some UTF-8 Chinese characters to file with following php codes: <code> ....... $fp = fopen($filepath,'wb'); fwrite($fp,$utf8string,strlen($utf8string)); fclose($fp);...
5
by: Ma Siva Kumar | last post by:
Running postgresql-7.3.2-3 which came with Red Hat 9.0. Created a database with unicode encoding (in psql) as below: create database leatherlink with encoding='unicode' template=leatherlinkdb;...
18
by: Zygmunt Krynicki | last post by:
Hello I've browsed the FAQ but apparently it lacks any questions concenring wide character strings. I'd like to calculate the length of a multibyte string without converting the whole string. ...
3
by: yazan jab | last post by:
Is it true that Multibyte characters are : char arrays (witch represent a string from the basic characters set). In this case Wide characters are the way for encoding characters from the...
3
by: Weiping | last post by:
Hi, while upgrade to 8.0 (beta3) we got some problem: we have a database which encoding is UNICODE, when we do queries like: select upper('ÖÐÎÄ'); --select some multibyte character, then...
5
by: Karthik | last post by:
Hello! I am not a wizard in this area! Just need some help out in this. I am trying to convert bstr string to new character string. Here is the snippet of my code. **** Code Start**** ...
1
by: Marcel Ruff | last post by:
Hi, i have the question on how to determine the string length of a wide string and a multibyte string: 1. Number of letters (one letter may use three bytes) 2. Number of bytes In the code...
13
by: TK | last post by:
Hi, how can I handle multibyte characters like ä, ü (german vowel mutation)? This does't work: switch(c) case 'ä': ... some action
2
by: George2 | last post by:
Hello everyone, I need to know the wide character (unicode) and multibyte (UTF-8) values of a character string of czech. I personally know nothing about czech. Is the following approach correct?...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.