all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: joakim@verona.se
Cc: emacs-devel@gnu.org
Subject: Re: String handling in xwidget primitives
Date: Fri, 29 Jan 2016 22:25:15 +0200	[thread overview]
Message-ID: <837fisxhec.fsf@gnu.org> (raw)
In-Reply-To: <m3lh78rxwe.fsf@exodia.verona.se> (joakim@verona.se)

> From: joakim@verona.se
> Date: Fri, 29 Jan 2016 20:25:21 +0100
> 
> I briefly tested this:
> 
> (xwidget-webkit-execute-script (xwidget-at 0) "alert('𝌆')")
> 
> where 𝌆 is some kind of unicode char i stole from
> 
> https://mathiasbynens.be/notes/javascript-encoding
> this page seems to indicate utf-16 is used.

I've seen such claims.  But they cannot be true, since if they were,
we couldn't have passed pure ASCII strings to those interfaces without
triggering weird errors: each ASCII character takes 2 bytes in UTF-16,
not one.

I think UTF-16 is used internally to represent strings, but the script
itself should not be in UTF-16.  I think it should be either in UTF-8
(and then requires a BOM), or it should include the charset= metadata
to indicate its encoding.

> I executed the code in a buffer containing a webkit instance, and the
> char showed up in an alert box originating from the wekit instance.
> 
> This doesnt actually prove anything, but it does seem to show that in my
> case on my machine and environment, at least something goes right.

Sheer luck: you just didn't bump into all those subtleties which make
the internal representation of strings in Emacs be a superset of
UTF-8, but not exactly UTF-8.

> If we do need to encode, do you know some part of the emacs src i can
> see which functions to use?

It depends how we need to encode.  In general,
code_convert_string_norecord is the most frequently used function in
these cases.



       reply	other threads:[~2016-01-29 20:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <83bn84xn2p.fsf@gnu.org>
     [not found] ` <m3lh78rxwe.fsf@exodia.verona.se>
2016-01-29 20:25   ` Eli Zaretskii [this message]
2016-01-29 19:16 String handling in xwidget primitives Eli Zaretskii
2016-01-29 22:57 ` Paul Eggert
2016-01-30  7:57   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=837fisxhec.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=joakim@verona.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.