-1

Assume I've an array of strings which contain some chinese chars inside. Eg: " This is a sample 在按键 needs to be tested" ^ ^ | | start end

I need to extract only the chinese alone from the char array.

Thanks Vijay

  • Hope this will help : http://stackoverflow.com/questions/16228329/check-whether-a-cstring-contains-only-chinese-characters – ram May 05 '14 at 06:01

1 Answers1

0

Pseudo-code (in my gcc world ...sorry, no MS dev access tonight):

wcsncpy(wcDest, wcschr(" This is a sample 在按键 needs to be tested", "在"), 4);

The wcschr() function is the wide-character equivalent of the strchr() function.

From the wcschr() man page:

"It searches the first occurrence of wc in the wide-character string pointed to by wcs."


The wcsncpy() function is the wide-character equivalent of the strncpy().

From the wcsncpy() man page:

"It copies at most n wide characters from the wide-character string pointed to by src, including the terminating null wide character (Laq\0aq), to the array pointed to by dest. Exactly n wide characters are written at dest. If the length wcslen(src) is smaller than n, the remaining wide characters in the array pointed to by dest are filled with null wide characters. If the length wcslen(src) is greater or equal to n, the string pointed to by dest will not be terminated by a null wide character."

Mahonri Moriancumer
  • 5,993
  • 2
  • 18
  • 28
  • Sorry I tried debugging the issue more. Now the issue is – user1581317 May 05 '14 at 08:56
  • Sorry I tried debugging the issue more. I'll brief the problem. I've a set of xml replies received from the server, which has the Chinese chars. Once the reply is received I'll be writing into the file using the CreateFile & WriteFile API. After that I'm trying to read the from the same file using ReadFile API. When I debug, the char buffer that I read from file is not having the same chinese chars what is there in file. – user1581317 May 05 '14 at 09:04