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

Home Posts Topics Members FAQ

Unicode entities in email subject

Dear Group,

my first post to this group, so if I'm on the wrong group, my
apologies.

I'm trying to send out an email in Chinese lanuage using the mail()
function in PHP.

Subject and mailbody are stored as Unicode entities (eg. 註)

The mail body renders perfectly in all tested emailclients if the mail
is sent as html.

Only the subject displays the entities but does not render the Chinese
chars.

Any ideas on how to get the mail sent with the subject displaying
correctly?

Thank you in advance for any clue available on this topic.

Patrick Huss

Dec 8 '06 #1
3 8747
On 8 Dec 2006 07:29:39 -0800, "Laangen_LU " <pa**********@g mail.comwrote:
>my first post to this group, so if I'm on the wrong group, my
apologies.

I'm trying to send out an email in Chinese lanuage using the mail()
function in PHP.

Subject and mailbody are stored as Unicode entities (eg. 註)

The mail body renders perfectly in all tested emailclients if the mail
is sent as html.

Only the subject displays the entities but does not render the Chinese
chars.

Any ideas on how to get the mail sent with the subject displaying
correctly?

Thank you in advance for any clue available on this topic.
Encoding in headers of mail messages uses a different scheme to HTML. I
believe the specification you want is RFC 1342 "Representa tion of Non-ASCII
Text in Internet Message Headers" (http://rfc.net/rfc1342.html)

You'll likely have to decode the subject's HTML entity references and recode
them as above.

--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Dec 8 '06 #2
"Laangen_LU " <pa**********@g mail.comwrote:
my first post to this group, so if I'm on the wrong group, my
apologies.

I'm trying to send out an email in Chinese lanuage using the mail()
function in PHP.

Subject and mailbody are stored as Unicode entities (eg. 註)

The mail body renders perfectly in all tested emailclients if the mail
is sent as html.

Only the subject displays the entities but does not render the Chinese
chars.

Any ideas on how to get the mail sent with the subject displaying
correctly?

Thank you in advance for any clue available on this topic.
The "Subject" field can be encoded as MIME header (see RFC 2045-2048).
For example, given the subject $subj encoded as a UTF-8 string,
a possible encoding might be

define("ENCODIN G", "UTF-8");

$header = "Subject: =?" . ENCODING . "?B?" . base64_encode($ subj) . "?=\r\n";

Note that the RFC 2047 sets a limit to the maximum lenght of the resulting
string. Beyond that limit the string must be splitted somewere. However,
the email clients I tested are able to accept a string of any length,
so this is a problem you may ignore as a first step of the implementation.

And note that this encoding has nothing to do with the Content-Type
field or the body of the message.

Obviously, your "Unicode entities" must be converted to regular UTF-8
characters before the Base64 encoding be applied.

Regards,
___
/_|_\ Umberto Salsi
\/_\/ www.icosaedro.it

Dec 8 '06 #3
Thank you very much Umberto and Andy for your help.

The script is working now and Chinese emails arrive with nice rendrered
Chinese subjects lines.

I found the following function written by ronen to convert Unicode
entities back to a unicode string:

http://www.zend.com/codex.php?id=838&single=1

Using this before doing the base64 encoding does the trick.

Cheers,
Patrick Huss
Umberto Salsi schrieb:
"Laangen_LU " <pa**********@g mail.comwrote:
my first post to this group, so if I'm on the wrong group, my
apologies.

I'm trying to send out an email in Chinese lanuage using the mail()
function in PHP.

Subject and mailbody are stored as Unicode entities (eg. 註)

The mail body renders perfectly in all tested emailclients if the mail
is sent as html.

Only the subject displays the entities but does not render the Chinese
chars.

Any ideas on how to get the mail sent with the subject displaying
correctly?

Thank you in advance for any clue available on this topic.

The "Subject" field can be encoded as MIME header (see RFC 2045-2048).
For example, given the subject $subj encoded as a UTF-8 string,
a possible encoding might be

define("ENCODIN G", "UTF-8");

$header = "Subject: =?" . ENCODING . "?B?" . base64_encode($ subj) . "?=\r\n";

Note that the RFC 2047 sets a limit to the maximum lenght of the resulting
string. Beyond that limit the string must be splitted somewere. However,
the email clients I tested are able to accept a string of any length,
so this is a problem you may ignore as a first step of the implementation.

And note that this encoding has nothing to do with the Content-Type
field or the body of the message.

Obviously, your "Unicode entities" must be converted to regular UTF-8
characters before the Base64 encoding be applied.

Regards,
___
/_|_\ Umberto Salsi
\/_\/ www.icosaedro.it
Dec 11 '06 #4

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

Similar topics

30
2766
by: aurora | last post by:
I have long find the Python default encoding of strict ASCII frustrating. For one thing I prefer to get garbage character than an exception. But the biggest issue is Unicode exception often pop up in unexpected places and only when a non-ASCII or unicode character first found its way into the system. Below is an example. The program may runs fine at the beginning. But as soon as an unicode character u'b' is introduced, the program boom...
5
4417
by: Nancy | last post by:
I recently completed a web page, "Browser Tests of Entities in 2004". http://www.santagata.us/characters/CharacterEntities.html It shows those characters that work in all of the version 5.2+ browsers that were tested and those that only work in some of them. Take a look, maybe you'll consider it useful. This is not my field (I'm an architect - you know the house construction kind), so if you notice any inaccuracies I'd appreciate a...
1
3209
by: Mark Johnson | last post by:
I wonder if anyone has a solution? I wanted to use the web browser control as a 'zoom' box for a smaller textbox. I can format in the control, and save whatever formatting as HTML code back to the textbox when the web browser is closed. The only problem comes in the use of numeric entities to specify Unicode. The web browser control is fine when it comes to named entities, like &nbsp; . And there are a lot of named entities, just...
3
1620
by: Robin Haswell | last post by:
Hey guys I'm currently screenscraping some Swedish site, and i need a method to convert XML entities (&amp; etc, plus d etc) to Unicode characters. I'm sure one of python's myriad of XML processors can do this but I can't find which one. Can anyone make any suggestions? Thanks
1
2107
by: zunbeltz | last post by:
Hi, I'm parsing html. I have a page with a lot of html enitties for hebrew characters. When i print what i get are blanks, dots and commas. How can i decode this entities to unicode charachters? TIA Zunbeltz
8
2811
by: lorenzo.viscanti | last post by:
X-No-Archive: yes Hi, I've found lots of material on the net about unicode html conversions, but still i'm having many problems converting unicode characters to html entities. Is there any available function to solve this issue? As an example I would like to do this kind of conversion: \uc3B4 =&ocirc; for all available html entities. thanks,
2
2804
by: Frantic | last post by:
I'm working on a list of japaneese entities that contain the entity, the unicode hexadecimal code and the xml/sgml entity used for that entity. A unicode document is read into the program, then the program sorts out every doublet and the hexadecimal unicode code is extracted, but I dont know a way to find the xml or sgml-entity equivalent to the unicode code. Anyone who could give me a pointer? Best regards
6
4705
by: Clodoaldo | last post by:
I was looking for a function to transform a unicode string into htmlentities. Not only the usual html escaping thing but all characters. As I didn't find I wrote my own: # -*- coding: utf-8 -*- from htmlentitydefs import codepoint2name def unicode2htmlentities(u):
2
4882
by: neovantage | last post by:
hey geeks, I am using a function which convert unicode to entities. So that i can save values into mysql database into entities. This function really helps me when i display the store entity data into web page n it shows special charactor easily. Here is the function code function charset_decode_utf_8($string) { /* Only do the slow convert if there are 8-bit characters */ /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not...
0
9636
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
10306
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10139
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
7485
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
5373
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...
0
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
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
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
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.