Hi Alain,
>>> //REQUEST HB_CODEPAGE_FR850//
>>> //REQUEST HB_CODEPAGE_UTF8//
>>
>>> //......//
>>
>>> cBody=hb_utf8tostr(memoread(cBody))
>>
>> I suppose you are also setting the codepage to "FR850" inbetween those
>> lines,
> No, I don't set it.
If you are not setting the codepage for the VM, then the default is
used: "EN", which is a 437 OEM codepage.
>> so you are getting <cBody> translated to that codepage, right?
> I don't know how works hb_utf8tostr(), but on the screen, I see that the
> change is done.
What is shown on the screen is also affected by the codepage used by the
VM. For analyzing the result without risking side effects converting it
to hex is safer.
> The principal reason, I use hb_utf8tostr() is that all the string
> manipulations functions works, instead of using utf8 (strtran,
> substr,...), and it's easier to convert from str to ansi than from utf8
> to ansi.
HB_Translate() can convert from any codepage to any codepage and
HB_Utf8ToStr() and HB_StrToUtf8() can convert between UTF-8 and any
8-bit codepage ("str" can be text in any 8-bit codepage, see below).
>> And that is also not what HB_SendMail() expects.
> All my test shows that sendmail expected ansi.
It is really all about what HB_SendMail() tells the receiving mail
client to interpret the text as, and that happens in the Content-Type
header where the <cCharSet> argument is put if it is passed. If not
passed, "ISO-8859-1" is used by default:
Content-Type: text/plain; charset="ISO-8859-1"
If your body of text is not in ISO-8859-1 then you have to pass the
<cCharSet> argument to match it.
> In a previous answer you're talking of hb_sendmail() about the fact that
> the doc wasn't up to date.
> I agree, and now, there are 25 parameters instead of the doc included in
> hb_sendmail.prg
>
> In the prg, there is this:
>
> / hb_default( @cCharset, "ISO-8859-1" )//
Yes, that is where it goes wrong if you pass UTF-8 data and no UTF-8
<cCharSet> argument.
> I know the Charset parameter, but in gmail, it's not used (NIL),
If you mean the gmail.prg sample code, then it is just an incomplete
sample. Add the missing arguments and the problem should be solved.
> an in
> mine too. I think that this parameter is used for html code.And here I'm
> using ansi testfile.
I noticed in your other post that you have now seen the light :-)
> What could be the value to use to have a correct text ?
Pass "UTF-8" in the <cCharSet> argument
> What is the result encoding of hb_utf8tostr() ?
2007-06-23 11:10 UTC+0200 Przemyslaw Czerpak (druzus/at/
priv.onet.pl)
[...]
* harbour/source/rtl/cdpapi.c
+ added two prg functions for translations from/to UTF-8:
HB_STRTOUTF8( <cStr> [, <cCPID> ] ) -> <cUTF8Str>
HB_UTF8TOSTR( <cUTF8Str> [, <cCPID> ] ) -> <cStr>
<cCPID> is Harbour codepage id, f.e.: "EN", "ES", "ESWIN",
"PLISO", "PLMAZ", "PL852", "PLWIN", ...
When not given then default HVM codepage (set by HB_SETCODEPAGE())
is used.
Regards,
Klas