help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to calculate the size of string in bytes?


From: Sam Halliday
Subject: Re: how to calculate the size of string in bytes?
Date: Tue, 18 Aug 2015 05:06:39 -0700 (PDT)
User-agent: G2/1.0

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]