Page 1 of 1

unicode problem

Posted: 23 Mar 2015 9:56
by meriem
Hi i 'm a beginner with prolog, and i have a unicode problem, while i use the function write to write in a file i don't have the out put i want .
ps: the function write has a term argument wich is in arabic,
thank you so much

Posted: 23 Mar 2015 12:02
by Peter Muraya
Meriem, I would understand the problem better if can you provide:-
- the sample Prolog source code you are using
- the sample output are you getting and
- a statement of what were you expecting to get.

Posted: 23 Mar 2015 14:12
by meriem
Hello, thx for your reply :
For the predicate i would to save : الجملةالمفيدة(الجملةالفعلية((فعل_أمر(اكتب) , مفعول_به(اسم(الدرسَ)))), حرف_عطف(ثمَّ), الجملةالفعلية(فعل_أمر(العب))) // it's in arabic
in the file that i would like to save it, it apears like this : 㼿㼿㼿㼿㼿㼿㼨㼿㼿㼿㼿㼿㼿㼨⠿㼿弿㼿⠿㼿㼩‬‿㼿㼿弿㼨㼿㼨㼿㼿㼿⤩⤩Ⱐ㼿㽟㼿㼨㼿㼿⤬‿㼿㼿㼿㼿㼿㼿⠿㼿弿㼿⠿㼿㼩⤩

Posted: 23 Mar 2015 14:23
by Tonton Luc

Posted: 23 Mar 2015 15:04
by meriem
hello Tonton Luc , thx for your post i have seen that post to day but the problem is that i don't want to replace caractere by another cause the out put is not a clear caractere ont the saved file, i m searching for a way to encode the function write in prolog to make it compatible with arabic ( i mean it can recognize arabic caracteres )

Posted: 24 Mar 2015 11:04
by Tonton Luc
Hi,

:idea: Look in codePageId.pro (in pfc\codePageId package), you've some code about arabic...

This code work fine in my machine :

Code: Select all

        Txt = "...tape your arabic text here...",         F = outputStream_file::create(@"test_arabic.txt",stream::ansi(core::codepage(codepageId::utf8))),         F:write(Txt),         F:close(),

Posted: 25 Mar 2015 11:23
by meriem
Hii, thx for your reply i've tried it but it does not function because my Term is a composed term of arabic caracters so i moved from amzi prolog to swi prolog on eclipse but i got this error

ERROR: C:/...../infile_parse.pro:1:
writeq/1: I/O error in write on stream <stream>(07B59408) (Encoding cannot represent character)

how can i solve it ?? thx a lot , and sorry for disturbing

Posted: 26 Mar 2015 7:51
by Tonton Luc
Hi,

Sorry but I can't help you more because I don't know amzi and swi Prolog.
:cry:

Posted: 26 Mar 2015 10:46
by Thomas Linder Puls
This clearly looks like an encoding problem.

It could look like you expect utf16 encoding. This will write the text to an utf16 encoded file:
clauses
run() :-
S = "For the predicate i would to save : &#1575;&#1604;&#1580;&#1605;&#1604;&#1577;&#1575;&#1604;&#1605;&#1601;&#1610;&#1583;&#1577;(&#1575;&#1604;&#1580;&#1605;&#1604;&#1577;&#1575;&#1604;&#1601;&#1593;&#1604;&#1610;&#1577;((&#1601;&#1593;&#1604;_&#1571;&#1605;&#1585;(&#1575;&#1603;&#1578;&#1576;) , &#1605;&#1601;&#1593;&#1608;&#1604;_&#1576;&#1607;(&#1575;&#1587;&#1605;(&#1575;&#1604;&#1583;&#1585;&#1587;&#1614;)))), &#1581;&#1585;&#1601;_&#1593;&#1591;&#1601;(&#1579;&#1605;&#1617;&#1614;), &#1575;&#1604;&#1580;&#1605;&#1604;&#1577;&#1575;&#1604;&#1601;&#1593;&#1604;&#1610;&#1577;(&#1601;&#1593;&#1604;_&#1571;&#1605;&#1585;(&#1575;&#1604;&#1593;&#1576;))) // it's in arabic",
O = outputStream_file::create("arab.txt"),
O:write(S),
O:close().
Which program do you use for determining how "it looks in the file"?