From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sam Halliday Newsgroups: gmane.emacs.help Subject: Re: how to calculate the size of string in bytes? Date: Tue, 18 Aug 2015 05:06:39 -0700 (PDT) Message-ID: <27059cc8-2f14-4d6b-8397-053282881556@googlegroups.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1439901545 19222 80.91.229.3 (18 Aug 2015 12:39:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Aug 2015 12:39:05 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Aug 18 14:38:58 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZRgAK-0004k0-D3 for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Aug 2015 14:38:56 +0200 Original-Received: from localhost ([::1]:56389 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZRfji-0002GC-R6 for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Aug 2015 08:11:26 -0400 X-Received: by 10.13.220.68 with SMTP id f65mr5459639ywe.16.1439899600204; Tue, 18 Aug 2015 05:06:40 -0700 (PDT) X-Received: by 10.140.95.79 with SMTP id h73mr79592qge.30.1439899600182; Tue, 18 Aug 2015 05:06:40 -0700 (PDT) Original-Path: usenet.stanford.edu!69no1874277qgi.0!news-out.google.com!78ni15675qge.1!nntp.google.com!y105no1344537qge.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=83.244.128.25; posting-account=kRukCAoAAAANs-vsVh9dFwo5kp5pwnPz Original-NNTP-Posting-Host: 83.244.128.25 User-Agent: G2/1.0 Injection-Date: Tue, 18 Aug 2015 12:06:40 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.help:214389 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:106668 Archived-At: On Tuesday, 18 August 2015 12:47:15 UTC+1, to...@tuxteam.de wrote: > > We're not sending the message using raw, we're using UTF-8. But I need to calculate the length of the UTF-8 string IN BYTES as part of the payload (each messages begins with a 6 character hex encoding of the proceeding string's raw length). > > Yes, I get that. The way I understand encode-coding-string is that you give > it the target encoding: > > (length (encode-coding-string foo 'raw-text)) Aah, ok, I didn't get what you were saying. I thought `utf-8' here would just give me back the original. OK, so I really need (length (encode-coding-string "EURO" 'utf-8)) and actually, since the process can be using a different encoding, I need (length (encode-coding-string "EURO" my-encoding)) Thanks! I already pushed a quick fix, but this seems more solid.