Thread Subject: Displaying Unicode using editor cell mode publish (utf-8 encoded

Subject: Displaying Unicode using editor cell mode publish (utf-8 encoded

From: Freelance Embedded Systems Engineer

Date: 13 May, 2008 16:09:49

Message: 1 of 2

I have a UTF-8 encoded byte array consisting of the hexadecimal numerical values, for example the 3-byte array (a): "E2 99 A0".

I can convert this array using "b=native2Unicode(a,'UTF-8') to obtain a 2-byte character string, but I want to be able to view the result, (in this example, the Black Spade Suit character, Unicode 02660).

Since I believe that Matlab can't display this in the command window[1], I would like to display this in the HTML results produced by the Publish process, (M-file editor cell mode option). The resulting HTML file does have a "meta" definition in the <head> that includes:

    contents="text/html; charset=utf-8".

So I'm trying to figure out what Matlab commands I need to issue in order to get the desired result from the UTF-8 encoded array, or if I need to learn about style sheets to get the desired result.

Note
[1] I've tried various desktop code fonts in the preferences including Arial Unicode MS which displays a square box for the desired result in the example below.


- - - - - - - - - - - - - - - - - - - - - - - - - - - -
         Example Matlab code
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
a=uint8([hex2dec('E2'),hex2dec('8C'),hex2dec('A0')])
     226 140 160

b=native2unicode(a,'UTF-8')

    %nothing displayed in monospace fonts
    %empty square box displayed in Arial Unicode MS

whos
    Name Size Bytes Class
    a 1x3 3 uint8
    b 1x1 2 char
- - - - - - - - - - - - - - - - - - - - - - - - - - - -



Reference URLs:
http://isthisthingon.org/unicode/index.phtml?page=02&subpage=6&glyph=02660
http://www.fileformat.info/info/unicode/utf8.htm

g9u5dd43@yahoo.com

Subject: Displaying Unicode using editor cell mode publish (utf-8 encoded

From: Matthew Simoneau

Date: 20 May, 2008 06:28:02

Message: 2 of 2

The only thing I can think of is to escape it yourself and
then use the <html> tag to pass it straight through. This
code should get you started:

a = uint8([hex2dec('E2'),hex2dec('8C'),hex2dec('A0')]);
b = native2unicode(a,'UTF-8');
c = uint16(b);
fprintf('<html>&#%.0f;</html>\n',c)

It seems like this should be handled automatically, but I
need to do some more digging.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
unicode Thomas Montagnon 17 Sep, 2008 03:57:51
unicode Matthew Simoneau 20 May, 2008 02:47:36
publish Matthew Simoneau 20 May, 2008 02:47:28
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com