On Fri, Sep 30, 2005 at 11:53:02AM +0800, Jack Liu wrote:
> Dear All,
>
> I have the same problem on qmail-reply .
>
> I use php to make a form that can let user use their personal mailreplytext.
> But I cannot save chinese word to openldap database. So, I try to use php
> function base64_encode() and base64_decode() in my php code.
>
> Like that:
>
> mailReplyText update function()
> $newreplytext = base64_encode($_POST['replytext']);
> $add_attribs[$mailreplytext_field] = array("$newreplytext");
> $result = ldap_modify($ds,$dn,$add_attribs);
>
> User php form
> $val1 = @ldap_get_values($ds,$info,$mailreplytext_field);
> <textarea rows=8 cols=50 name=replytext>' . base64_decode($val1[0])
> .'</textarea>
>
> This is work for me.
>
> But, the problem is, qmail-reply send reply email without decode from
> base64.
>
> So, the Sender will see the following messages:
>
> tPq41Q==
>
> I know ldap will store the value using UTF8 format.
> But, I don't know how to make the Sender recieve the correct reply messages
> in chinese word(double bytes).
>
> Can anybody show me the light?
Normaly you have to convert the incomming string (probably UTF-16) to
UTF-8. This can be added to LDAP and qmail-reply will do the right thing.
qmail-reply uses UTF-8 as default encoding. For other encodings you should
have to modify qmail-ldap.h
For my scripts I use this stupid perl script to convert the ISO latin1
chars to utf8 (I never had to deal with chinese chars):
#!/usr/bin/perl
use encoding "latin1", STDOUT => "utf8";
while(<>){print};
There is a man page for encoding installed with perl with some hints on
how to use it.
--
:wq Claudio