Bug wprintf , putwchar + fbc?

Linux specific questions.
Post Reply
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Bug wprintf , putwchar + fbc?

Post by VANYA »

Hi all!

Code: Select all

#include "crt.bi"
'#include "crt/locale.bi" 
'setlocale(LC_ALL, "")
dim as wstring*10 ws = "AAA"
wprintf(@wstr(!"%C") , 1079) ' Not Work!!!!!!!!!!!!!
wprintf(@wstr(!"%c") , 1079) ' Not Work!!!!!!!!!!!!!
wprintf(@wstr("hello")) ' Not Work!!!!!!!!!!!!!
wprintf(@ws)  ' Not Work!!!!!!!!!!!!!
dim as long i = getwchar
putwchar(1079) ' output "7" instead "з"
' ? i ' can not use getwchar + fb print , otherwise there will be garbage in the terminal https://www.freebasic.net/forum/viewtopic.php?t=31621

Similar C\C++ code works correctly:

Code: Select all

#include "stdio.h"
#include "locale.h"
int main()
{
	setlocale(LC_ALL, "");
	int i = 1079;
	wprintf(L"%C" , i); // ok!!!
	putwchar(1079); // ok!!!
}
coderJeff
Site Admin
Posts: 4313
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Bug wprintf , putwchar + fbc?

Post by coderJeff »

I thought I read that printf() and wprintf() can't be mixed on the same stream. Like either the stdout is configured for chars or wchars. But I'm not 100% sure about that. If that's true though, it would be related to fb runtime taking control of the terminal's input and output streams right from the start when a program is first run.
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: Bug wprintf , putwchar + fbc?

Post by VANYA »

coderJeff wrote: I thought I read that printf() and wprintf() can't be mixed on the same stream.
It seems so. I don't know the source code of the compiler, perhaps creating a choice between (printf or wprintf) for users - is not an easy task. But in any case, if FB by default disables some CRT functions without the possibility of using them, this is a bad option. Thank you for your interest in this topic!
Post Reply