Tk Library Source Code

View Ticket
Login
Ticket UUID: 1178045
Title: Bad conversion for UTF-8 strings
Type: Bug Version: None
Submitter: nobody Created on: 2005-04-06 20:09:06
Subsystem: ldap Assigned To: loewerj
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2006-09-01 21:23:32
Resolution: Invalid Closed By: mic42
    Closed on: 2006-09-01 14:23:32
Description:
UTF-8 are not handled correctly in LDAP module (or may be 
ASN). 
 
Repeat by: 
 
---------------------------------------------- 
package require ldap 
set x [::ldap::connect ldap.u-strasbg.fr] 
set y [::ldap::search $x o=ulp {(cn=*jamet an*)} *] 
set z [lindex $y 0] 
array set t [lindex $z 1] 
puts $t(cn) 
--------------------------------------------- 
 
I get UTF-8 characters on dislay, even if stdout is 
fconfigured with the normal "iso8859-15" encoding.
User Comments: pdav added on 2005-07-18 03:13:47:
Logged In: YES 
user_id=1268042

This is not a bug in the LDAP module.  
   
According to RFC 2251, paragraph 4.1.2, only "LDAPString" types are  
encoded in UTF8. Decoding depends on the schema used. 
 
This should be made clear in the documentation.

mic42 added on 2005-04-13 02:30:20:
Logged In: YES 
user_id=302287

According to RFC 2253 the string should probably be
converted to the UTF-8 encoding.
http://www.ietf.org/rfc/rfc2253.txt
and
http://www.ietf.org/rfc/rfc2251.txt
(Section 4.1.2).
So yes, this is a bug und output should be converted to
utf-8 or the encoding given in RFC 2253. Direct access to
the ASN.1 values should be optionally possible.

mic42 added on 2005-04-07 03:32:06:
Logged In: YES 
user_id=302287

The ldap package probably just returns the ASN OctetString
type and does not interpret it in any further, but the
application is free to interpret it in the way it likes to.
I need to check the LDAP RFC what is expected to happen with
the search result encodingwise.

nobody added on 2005-04-07 03:19:49:
Logged In: NO 

Workaround:  
  
----------------------------------------------  
puts [encoding convertfrom utf-8 $t(cn)]  
----------------------------------------------  
 
Why UTF-8 strings resulting from a LDAP search are not 
automagically converted into Unicode to be handled like 
normal strings?