473,779 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UTF-8 to HTML conversion


Hi all,

is there any kind of 'hiconv' or other (unix-like) conversion tool that
would convert UTF-8 to HTML (ISO-Latin-1 and Unicode)?

The database output is UTF-8 or UTF-16 only - Thus almost every character
starts with ^@.

I've seen e.g.
http://aktuell.de.selfhtml.org/artik...64/utf8.htm#a5 as
JavaScript decoder - but maybe there's a recommended little helper that
could do:

- get rid of UTF-8 declarations where Latin is good enough
- convert others to most widely used HTML

such as Bulgarian and Russian charsets to &#10..;
.... or even ISO-Latin-1 8bits to HTML
ä -> ä
.... and maybe
EUR -> €

Thanks,
Martin
Jul 23 '05 #1
22 11957
In article <sl************ ******@id-685.user.indivi dual.de>,
Martin Trautmann <tr***@gmx.de > wrote:

Hi all,

is there any kind of 'hiconv' or other (unix-like) conversion tool that
would convert UTF-8 to HTML (ISO-Latin-1 and Unicode)?

The database output is UTF-8 or UTF-16 only - Thus almost every character
starts with ^@.

I've seen e.g.
http://aktuell.de.selfhtml.org/artik...64/utf8.htm#a5 as
JavaScript decoder - but maybe there's a recommended little helper that
could do:

- get rid of UTF-8 declarations where Latin is good enough
- convert others to most widely used HTML

such as Bulgarian and Russian charsets to &#10..;
... or even ISO-Latin-1 8bits to HTML
ä -> &auml;
... and maybe
EUR -> &euro;


What's the problem with just using the UTF-8 output as is?

--
= Eric Bustad, Norwegian bachelor programmer
Jul 23 '05 #2
> is there any kind of 'hiconv' or other (unix-like) conversion tool
that
would convert UTF-8 to HTML (ISO-Latin-1 and Unicode)?


Martin,

HTML4 can be UTF-8; just serve it as content-type: text/html;
charset=utf-8. Alternatively put a META tag in the header that
declares it as such. Long ago HTML was restricted to Latin1 but that
is history. (Maybe there is more to this than you are telling us?)

Anyway, if you really want to convert Unicode to latin1 + html
character entities, I believe that GNU recode can do what you want:

$ recode utf8..html
Martel est considéré comme "père" de la spéléologie moderne
Martel est consid&eacute;r &eacute; comme &quot;p&egrave; re&quot; de la
sp&eacute;l&eac ute;ologie moderne

(Whether that example looks right depends on what happens to this post
between me and you...)

--Phil.

Jul 23 '05 #3
1. down load DELO editor
http://www.russiantext.ircdb.org/ruseditE.htm

2. type any Cyrillic text (editor works at NT/2000/XP, no Cyrillic font
setup or Cyrillic driver is required)

3. Select all or part of Cyrillic text

4. go to Format->Code convertion->Symbols to HTML Decimal Menu item

5. click and Cyrillic "privet" text will be converted to
привет

Bye
Smike
http://smike.ru
http://xedit.smike.ru
Martin Trautmann wrote:
Hi all,

is there any kind of 'hiconv' or other (unix-like) conversion tool that would convert UTF-8 to HTML (ISO-Latin-1 and Unicode)?

The database output is UTF-8 or UTF-16 only - Thus almost every character starts with ^@.

I've seen e.g.
http://aktuell.de.selfhtml.org/artik...64/utf8.htm#a5 as JavaScript decoder - but maybe there's a recommended little helper that could do:

- get rid of UTF-8 declarations where Latin is good enough
- convert others to most widely used HTML

such as Bulgarian and Russian charsets to &#10..;
... or even ISO-Latin-1 8bits to HTML
ä -> &auml;
... and maybe
EUR -> &euro;

Thanks,
Martin


Jul 23 '05 #4
On 1 Mar 2005 17:35:20 GMT, Eric Kenneth Bustad wrote:
What's the problem with just using the UTF-8 output as is?


it's not really UTF-8, but UTF-16. I don't have a major problem to make
UTF-8 from UTF-16 - just stripping the other byte. But then there are
some remaining chars which should get some further translation.

Example (sorry if my charset is incorrect):

->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


->

<h3><a name="01-5">Russian</a></h3><i>&25B >;H51A B20</i>. EKSMO-Press, 2001-07 (5-04-007995-8)<br>

->

<h3><a name="01-5">Russian</a></h3><i>Цвет Волшебства </i>. EKSMO-Press, 2001-07 (5-04-007995-8)<br>
Jul 23 '05 #5
On 1 Mar 2005 11:07:24 -0800, ph*******@treef ic.com wrote:
is there any kind of 'hiconv' or other (unix-like) conversion tool that
would convert UTF-8 to HTML (ISO-Latin-1 and Unicode)?


Martin,

HTML4 can be UTF-8; just serve it as content-type: text/html;
charset=utf-8. Alternatively put a META tag in the header that
declares it as such. Long ago HTML was restricted to Latin1 but that
is history. (Maybe there is more to this than you are telling us?)


I guess so - I suppose I should have written about UTF-16 instead of
UTF-8. UTF-8 could be just fine. However, the current UTF-16 is hardly
readable - as source file.
Anyway, if you really want to convert Unicode to latin1 + html
character entities, I believe that GNU recode can do what you want:

$ recode utf8..html
Martel est considéré comme "père" de la spéléologie moderne
Martel est consid&eacute;r &eacute; comme &quot;p&egrave; re&quot; de la
sp&eacute;l&eac ute;ologie moderne


ah, this would be an option. However, I'll have to exclude the real
&lt;, &gt; &quot;, &amp;
Thanks,
Martin
Jul 23 '05 #6
On 1 Mar 2005 13:14:20 -0800, Smike wrote:
1. down load DELO editor
http://www.russiantext.ircdb.org/ruseditE.htm

2. type any Cyrillic text (editor works at NT/2000/XP, no Cyrillic font
setup or Cyrillic driver is required)


Thanks, but that's not an option:
is there any kind of 'hiconv' or other (unix-like) conversion tool that ^^^^^^^^^ would convert UTF-8 to HTML (ISO-Latin-1 and Unicode)?


I don't have any Win, but Solaris and Mac OSX.
Jul 23 '05 #7
Martin Trautmann wrote:
On 1 Mar 2005 17:35:20 GMT, Eric Kenneth Bustad wrote:
What's the problem with just using the UTF-8 output as is?

it's not really UTF-8, but UTF-16. I don't have a major problem to make
UTF-8 from UTF-16 - just stripping the other byte.


Stripping away one byte from a UTF-16 character does not necessarily
produce the equivalent UTF-8 character. That would only apply to the
US-ASCII subset of Unicode, for which the high-order octet is set to 0
and the low-order octet matches the US-ASCII character, but does not
apply to any other character.

However any program that performed such a conversion like that is
extremely broken. Read the Unicode spec and implement it properly, or
use some existing libraries that have already been written correctly for
the job, just don't implement it the way you suggested above.

--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox
Jul 23 '05 #8
>>> convert UTF-8 to HTML (ISO-Latin-1 and Unicode)?
HTML4 can be UTF-8; I guess so - I suppose I should have written about UTF-16 instead of
UTF-8. UTF-8 could be just fine. However, the current UTF-16 is

hardly readable - as source file


This is the best solution; just "recode UTF-16..UTF-8" and set up the
server to serve as UTF-8. If you're using Apache beware of how it sets
the default character set - the HTTP header's character set overrides
anything set in a META tag, and Apache now sets latin-1 as a default
(there are security issues behind this I believe). This caused me a
few hours of debugging once so I thought I'd mention it.
$ recode utf8..html

ah, this would be an option. However, I'll have to exclude the real
&lt;, &gt; &quot;, &amp;


Then you need -d:

$ recode -d utf8..html
<h1>¿Dondé?</h1>
<h1>&iquest;Don d&eacute;?</h1>

--Phil.

Jul 23 '05 #9
Martin Trautmann wrote:
On 1 Mar 2005 11:07:24 -0800, ph*******@treef ic.com wrote:
HTML4 can be UTF-8; just serve it as content-type: text/html;
charset=utf-8...


I guess so - I suppose I should have written about UTF-16 instead of
UTF-8. UTF-8 could be just fine. However, the current UTF-16 is hardly
readable - as source file.


Why not? You just need to get an editor that supports UTF-16, rather
than an editor that only supports ISO-8859-1 (though most usually
support Windows-1252 and call it ISO-8859-1, or equivalent, anyway)
Anyway, if you really want to convert Unicode to latin1 + html
character entities, I believe that GNU recode can do what you want:

$ recode utf8..html
Martel est considéré comme "père" de la spéléologie moderne
Martel est consid&eacute;r &eacute; comme &quot;p&egrave; re&quot; de la
sp&eacute;l&eac ute;ologie moderne


What about for Unicode characters that aren't included within the
subsets with named character entity references in HTML4? Does it
produce numeric character references instead?

--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox
Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
4192
by: lawrence | last post by:
Someone on www.php.net suggested using a seems_utf8() method to test text for UTF-8 character encoding but didn't specify how to write such a method. Can anyone suggest a test that might work? Something that maybe gives 90% confidence that a given block of text is or is not UTF-8 encoded?
4
6401
by: Alban Hertroys | last post by:
Another python/psycopg question, for which the solution is probably quite simple; I just don't know where to look. I have a query that inserts data originating from an utf-8 encoded XML file. And guess what, it contains utf-8 encoded characters... Now my problem is that psycopg will only accept queries of type str, so how do I get my utf-8 encoded data into the DB? I can't do query.encode('ascii'), that would be similar to: >>> x =...
12
8230
by: Mike Dee | last post by:
A very very basic UTF-8 question that's driving me nuts: If I have this in the beginning of my Python script in Linux: #!/usr/bin/env python # -*- coding: UTF-8 -*- should I - or should I not - be able to use non-ASCII characters in strings and in Tk GUI button labels and GUI window titles and in raw_input data without Python returning wrong case in manipulated
38
5739
by: Haines Brown | last post by:
I'm having trouble finding the character entity for the French abbreviation for "number" (capital N followed by a small supercript o, period). My references are not listing it. Where would I find an answer to this question (don't find it in the W3C_char_entities document). -- Haines Brown brownh@hartford-hwp.com
6
18765
by: jmgonet | last post by:
Hello everybody, I'm having troubles loading a Xml string encoded in UTF-8. If I try this code: ------------------------------ XmlDocument doc=new XmlDocument(); String s="<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><a>Schönbühl</a>"; doc.LoadXml(s); doc.Save("d:\\temp\\test.xml");
6
13894
by: archana | last post by:
Hi all, can someone tell me difference between unicode and utf 8 or utf 18 and which one is supporting more character set. whic i should use to support character ucs-2. I want to use ucs-2 character in streamreader and streamwriter. How unicode and utf chacters are stored.
1
7292
by: sheldon.regular | last post by:
I am new to unicode so please bear with my stupidity. I am doing the following in a Python IDE called Wing with Python 23. äöü äöü '\xc3\xa4\xc3\xb6\xc3\xbc' u'\xe4\xf6\xfc' u'\xe4\xf6\xfc' äöü
4
2352
by: shreshth.luthra | last post by:
Hi All, I am having a GUI which accepts a Unicode string and searches a given set of xml files for that string. Now, i have 2 XML files both of them saved in UTF-8 format, having characters of different language. Although both of them are having UTF-8 as BoM, but only first file is having UTF-8 defined in XML declration at the top of the XML file as
23
5029
by: Allan Ebdrup | last post by:
I hava an ajax web application where i hvae problems with UTF-8 encoding oc chineese chars. My Ajax webapplication runs in a HTML page that is UTF-8 Encoded. I copy and paste some chineese chars from another HTML page viewed in IE7, that is also UTF-8 encoded (search for "china" on google.com). I paste the chineese chars into a content editable div. My Ajax webservice compiles an XML where the data from the content editable div is...
35
4356
by: Bjoern Hoehrmann | last post by:
Hi, For a free software project, I had to write a routine that, given a Unicode scalar value U+0000 - U+10FFFF, returns an integer that holds the UTF-8 encoded form of it, for example, U+00F6 becomes 0x0000C3B6. I came up with the following. I am looking for a more elegant solution, that is, roughly, faster, shorter, more readable, ... while producing the same ouput for the cited range. unsigned int
0
9632
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10136
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10071
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9925
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8958
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7478
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4036
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.