NO

Author Topic: mbstowcs and getwline  (Read 4839 times)

BlueD

  • Guest
mbstowcs and getwline
« on: October 31, 2010, 03:44:53 AM »
I cannot use mbstowcs(and mblen, mbtowc, etc.) to convert Chinese strings.
Is it a bug or missing feasure?

Pelles C 6.50 RC2:

Code: [Select]
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
#include <locale.h>

int main(void)
{
  const char *str = "大家好!";
  wchar_t wstr[100];

  setlocale(LC_ALL, "CN");
  if (mbstowcs(wstr, str, 99) != -1)
    wprintf(L"%ls\n", wstr);
  else
    wprintf(L"Error: cannot convert the string!\n");
  
  return 0;
}

And I think getwline doesn't work too, see here

Actually I think most functions about multibytes are not working properly.
« Last Edit: November 03, 2010, 01:48:49 AM by BlueD »

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: mbstowcs and getwline
« Reply #1 on: November 04, 2010, 06:14:48 PM »
Supporting Chinese has never been a priority, and I'm pretty sure it never will be.
I don't understand Chinese, I don't know what is needed to support it, and I don't have sufficient fundings to bother... sorry...
/Pelle

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: mbstowcs and getwline
« Reply #2 on: November 04, 2010, 07:59:18 PM »
Use wchar_t instead of char is the first I would do.

Unicode strings are of type wchar_t, only ANSI strings are of type char.

Code: [Select]
const wchar_t *str = L"大家好!";
---
Stefan

Proud member of the UltraDefrag Development Team

BlueD

  • Guest
Re: mbstowcs and getwline
« Reply #3 on: November 05, 2010, 03:40:07 AM »
Supporting Chinese has never been a priority, and I'm pretty sure it never will be.
I don't understand Chinese, I don't know what is needed to support it, and I don't have sufficient fundings to bother... sorry...

What a great statement!
You really should put this on you frontpage, then people like me won't be stupid enough to use your software.

"Pelles C -- Only for western developers!"
« Last Edit: November 05, 2010, 03:43:53 AM by BlueD »

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: mbstowcs and getwline
« Reply #4 on: November 05, 2010, 10:09:37 AM »
亲爱的BlueD,
我认为Pelle不会粗鲁,但要指出,他的主要兴趣是编译器的开发。他没有足够的时间去工作,具体问题不同的语言也。
正如您可以看到IDE的消息翻译工作都是由志愿者。
反正你的问题是由于widechar程序比从编译器更多。
在我的身边总是欢迎。

Dear BlueD,
I think that Pelle would not be rude, but would point out that his main interest is in compiler development. He don't have enough time to work also on issues specific to different languages.
As you can see the IDE message translations are done by volunteers.
Anyway the problems you have are due to the widechar routines more than from the compiler.
On my side you are always welcome.
« Last Edit: November 05, 2010, 11:41:57 AM by frankie »
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: mbstowcs and getwline
« Reply #5 on: November 19, 2010, 04:59:43 PM »
What a great statement!
You really should put this on you frontpage, then people like me won't be stupid enough to use your software.

"Pelles C -- Only for western developers!"
People as stupid as you wouldn't read that text anyway, so what's the point...??!!
/Pelle

top398

  • Guest
Re: mbstowcs and getwline
« Reply #6 on: April 08, 2014, 05:13:38 PM »
I encounted the same sitution. But at least, under windows, there is a pair of APIs: WideCharToMultiByte and MultiByteToWideChar, so problem is partial solved.

But all in all, please as far as possible to improve mbstowcs / wcstombs and others wchar_t function.

By the way: Pelle's C compiler is really very small, very easy to use.