From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Adrian Robert Newsgroups: gmane.emacs.devel Subject: Re: How to convert char from Emacs-20 internal to UTF-8? Date: Wed, 16 Mar 2005 14:19:16 -0500 Message-ID: <1edb21fc2b6a61e8bd8d7b4d77aec1ec@cogsci.ucsd.edu> References: <64cb038a0c479b993368280a127af987@cogsci.ucsd.edu> <87acp3jyqi.fsf-monnier+emacs@gnu.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (Apple Message framework v619.2) Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1111001960 20940 80.91.229.2 (16 Mar 2005 19:39:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 16 Mar 2005 19:39:20 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Mar 16 20:39:20 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DBeFL-0005Po-P1 for ged-emacs-devel@m.gmane.org; Wed, 16 Mar 2005 20:32:01 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DBeVU-0002vN-3J for ged-emacs-devel@m.gmane.org; Wed, 16 Mar 2005 14:48:40 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DBeTE-00026X-C1 for emacs-devel@gnu.org; Wed, 16 Mar 2005 14:46:20 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DBeT5-00021z-1L for emacs-devel@gnu.org; Wed, 16 Mar 2005 14:46:11 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DBeT3-0001yx-Qf for emacs-devel@gnu.org; Wed, 16 Mar 2005 14:46:09 -0500 Original-Received: from [140.251.1.25] (helo=smtp-in1.med.cornell.edu) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1DBe39-00022j-BY for emacs-devel@gnu.org; Wed, 16 Mar 2005 14:19:23 -0500 Original-Received: from mpx2.med.cornell.edu (pc113142-10.med.cornell.edu [140.251.11.119]) by smtp-in1.med.cornell.edu (Switch-3.1.6/Switch-3.1.6) with ESMTP id j2GJJGnb190542 for ; Wed, 16 Mar 2005 14:19:16 -0500 Original-Received: from [140.251.33.115] by mpx2.med.cornell.edu (Sun Java System Messaging Server 6.1 HotFix 0.11 (built Jan 28 2005)) with ESMTP id <0IDG009JZLO4Z800@mpx2.med.cornell.edu> for emacs-devel@gnu.org; Wed, 16 Mar 2005 14:19:16 -0500 (EST) In-reply-to: <87acp3jyqi.fsf-monnier+emacs@gnu.org> Original-To: Stefan Monnier X-Mailer: Apple Mail (2.619.2) X-PMX-Version: 4.7.1.128075, Antispam-Engine: 2.0.3.0, Antispam-Data: 2005.3.16.10 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org X-MailScanner-To: ged-emacs-devel@m.gmane.org Xref: news.gmane.org gmane.emacs.devel:34643 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:34643 On Mar 16, 2005, at 12:19 PM, Stefan Monnier wrote: >> I apologize for the "retro" question, but I was wondering if there >> was an >> easy way to convert a character in the Emacs-20 internal 19-bit >> encoding >> (from FAST_GLYPH_CHAR(glyph)) to UTF-8 (preferable) or straight >> Unicode. >> I'd like to do it fully within C if possible, and it needs to be >> efficient. > > Since Emacs-21's internal chars are a superset of Emacs-20's internal > chars, > you can just use Emacs-21's facilities like (encode-coding-string > 'utf-8) or (encode-char 'ucs). Thanks. Are the encode-coding-string and encode-char functions a) fast enough to be used inside of dumpglyphs() for screen rendering and b) something I can easily lift out of 21 and backport to 20? I'm asking because this is for a GNUstep/OS X interface for emacs 20 (http://emacs-on-aqua.sf.net/), and while we'd like to bring it up to date to work with the coming emacs-22 (where I assume this problem disappears completely), this is a large job and we'd like to have support for 2-byte font and other i18n rendering in the meantime. (In the OpenStep APIs, conversions to native font encoding are handled internally, so we don't need all of CCL's generality, but we need to get characters in UTF-8 or unicode to give to the APIs in the first place.)