Oracle 11g. PL/SQL. Oracle uses AL32UTF8.
LastName
--------
Manaña
The unicode value in Oracle for the ñ is (00F1) the ascii value is (0241). When I send this value in an email. The email reads ‘manan?a’.
The email value in HEX is (3F).
Question: How can I keep my ‘ñ’ when I send it via email?
Here’s select dump:
select dump(last_name) => [Typ=1 Len=7: 77,97,110,97,195,177,97]
When I send the email, I call package.mail
Here’s that snippet
last_name := 'Manaña'
packagename.mail(recipient ==>'emailrecipeint@blah.com',
subject ==>'Email Subject',
message ==>last_name);
PROCEDURE mail(sender IN VARCHAR2 default 'non-reply@company.edu',
recipients IN VARCHAR2,
subject IN VARCHAR2,
message IN VARCHAR2) IS
conn utl_smtp.connection;
userid varchar2(256);
globalname varchar2(256);
BEGIN
conn := begin_mail(sender, recipients, subject);
select global_name into globalname from global_name;
select user into userid from dual;
write_text(conn, message);
end_mail(conn);
END;
Here’s the snippet for package.write_text
PROCEDURE write_text(conn IN OUT NOCOPY utl_smtp.connection,
message IN VARCHAR2) IS
BEGIN
utl_smtp.write_data(conn, message);
END;
Mail is fundamentally 7-bit. To send anything else than 7-bit text/plain, encapsulate and encode it using MIME. In your case, it’s probably sufficient to delclare
Content-Type: text/plain; charset="utf-8"andContent-Transfer-Encoding: quoted-printable. Then if course you need to QP-encode your text; your language probably has a library for this. (It’s not hard to roll your own, but it’s usually a bad idea.)