留言板

encoding file name attachment

thumbnail
Alberto Martínez,修改在7 年前。

encoding file name attachment

New Member 帖子: 23 加入日期: 15-12-4 最近的帖子
Hi!!

I have one file to attach to my MailMessage object.
Its name must accept special character like á, é, í, ó, ú...
In other words, variable "name" have valor = "Luís.pdf", but file name is "Lu�s.pdf" finally

Any suggestion please?
thumbnail
David H Nebinger,修改在7 年前。

RE: encoding file name attachment

Liferay Legend 帖子: 14919 加入日期: 06-9-2 最近的帖子
Have you considered that the mail systems might not allow for encoded filenames? They tend to be kind of rigid since that kind of thing has been used to encode malicious files with names that users might otherwise open not knowing the content was tainted.
thumbnail
Alberto Martínez,修改在7 年前。

RE: encoding file name attachment

New Member 帖子: 23 加入日期: 15-12-4 最近的帖子
Thanks David!

I thought about that and I have find a solution. I hope this help somebody.

Normalizer.normalize(filename, Normalizer.Form.NFD).replaceAll("[^\\p{ASCII}]", "");


This is the most elegant I found.

Sorry for my bad english and thank you so much David. You are very fast answering.