PL_chars_to_term caracter encoding

Uwe Lesta <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <DADDA4CE0F00374BB9EA2BEDBFF2CCDF602BF228D9@SERVER.SBS.SBS-Softwaresysteme.de>
Hello List,

I'll try to feed SWI-Prolog (latest stabile release 6.6.2) with some Unicode chars. 

PL_chars_to_term() is the interesting part here. I'll try an utf8 encoding but I did not work.


     	PlCall("consult('d:/test.pl')");
	// save_term('eşek').
	// char str[19] = {'s','a','v','e','_','t','e','r','m','(',0x27, 0x65, 0xc5, 0x9f, 0x65,  0x6b, 0x27, ')', 0};
	// none('eşek').
	char str[14] = {'n','o','n','e','(',0x27, 0x65, 0xc5, 0x9f, 0x65,  0x6b, 0x27, ')', 0};
	// char str[8] = {0x27, 0x65, 0x65, 0x65, 0x65,  0x65, 0x27, 0};
	char * pStr = &str[0];
	bool b = PlCall(pStr);  // is false and should be true
	PlTerm t = PlCompound(pStr);	// an other test
	
How can this be done?

Any ideas are welcome.


Prolog helper file test.pl
--------------------------
save_term_to_file(File, Term) :-
	setup_call_cleanup(open(File, write, Out, [encoding(utf8)]),
			   format(Out, '~q .~n', [Term]),
			   close(Out)).

save_term(T):-
	save_term_to_file('d:\\test.out', T).

	% in Utf8 hex codes 65 c5 9f 65 6b
none('eşek').
--------------------------

-- 

Kind regards 

Uwe Lesta
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.