From owner-freebsd-i18n@FreeBSD.ORG Mon Feb 12 07:30:41 2007 Return-Path: X-Original-To: freebsd-i18n@freebsd.org Delivered-To: freebsd-i18n@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D9E7116A421 for ; Mon, 12 Feb 2007 07:30:41 +0000 (UTC) (envelope-from colinzhengj@gmail.com) Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.178]) by mx1.freebsd.org (Postfix) with ESMTP id 9FA7213C48E for ; Mon, 12 Feb 2007 07:30:41 +0000 (UTC) (envelope-from colinzhengj@gmail.com) Received: by py-out-1112.google.com with SMTP id f47so780504pye for ; Sun, 11 Feb 2007 23:30:40 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:date:to:subject:message-id:mail-followup-to:mime-version:content-type:content-disposition:user-agent:from; b=ftpL3LGzbt3h+z5xBSCpXUMSuC1kqEQr0OZvlCKwiKM95nfnGNp65VFpxL0mJhS2xxNsrrTOZ69hZiZhR8PLsDxg4S1z0g2CDXmd80KIjuCIXn9S/cioJ/VXgrpk0A0OODoYejmoPgNez1HCExUSv4qR7Cp1MIjFXDr+XRlum+Q= Received: by 10.35.20.14 with SMTP id x14mr15005062pyi.1171263935175; Sun, 11 Feb 2007 23:05:35 -0800 (PST) Received: from zjc ( [71.42.119.37]) by mx.google.com with ESMTP id 36sm9434295nza.2007.02.11.23.05.34; Sun, 11 Feb 2007 23:05:35 -0800 (PST) Date: Mon, 12 Feb 2007 01:06:03 -0600 To: freebsd-i18n@freebsd.org Message-ID: <20070212070603.GA4107@zjc.ch4.mdu> Mail-Followup-To: freebsd-i18n@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.2i From: "Jia Zheng (Colin)" Subject: wctomb bug? X-BeenThere: freebsd-i18n@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD Internationalization Effort List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Feb 2007 07:30:41 -0000 Hi all, Pardon me if this is not the right place to write. My program uses UTF-8 internally, and I wrote the below routine to convert a UTF-8 char using current encoding. 24 int utf8tomb (pchar_t pcmb, const pchar_t pc) 25 { 26 wchar_t wc; 27 setlocale (LC_CTYPE, "en_US.UTF-8"); 28 mbtowc (&wc, pc, MB_LEN_MAX); 29 setlocale (LC_CTYPE, "zh_CN.GB2312"); 30 return wctomb (pcmb, wc); 31 } Problem: wctomb works incorrectly with zh_CN.GB2312 (in fact, any encoding other than UTF-8 and C). When trying to convert a Chinese charactor, pcmb[0] always contains the decimal 17, and pcmb[1] is NULL. Howver this routine works fine in Ubuntu. That is, pcmb points to a string with length 2, not including the null terminator. Besides, mbtowc works correctly. Since setlocale() was successful, I believe the problem is with wctomb... -zhengjia