Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Webcast-Catalyst9k
New Member

Cisco TCL Other Language support

Hello I need some help. I write TCL script for IOS. Default script in ANSII coding format.

in script body I need use other language message:

append mail_pre "Subject: Информация\n\n"

And I receive mail with not readable value.

If I change coding for file like UTF-8 IOS get error, and not accept script.

Can I have way to use other language in tcl script?

1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

Cisco TCL Other Language support

Here is where you need additional headers to specify the MIME encoding.  For example:

append mail_pre "MIME-Version: 1.0\r\n"
append mail_pre "Content-Type: text/plain; charset=\"UTF-8\"\r\n"

7 REPLIES
Cisco Employee

Cisco TCL Other Language support

I don't think it's the encoding of the script that's the problem.  I think you need to specify the encoding of the message in the SMTP envelope.  Have a look at http://stackoverflow.com/questions/10752853/php-mailfrom-cyrrilic-encoding .  This gives you an example of how to adjust the headers in general.  You can do this same thing in Tcl by adding your headers after the default set of email headers.

For Base64 encoding, use ::base64::encode in EEM Tcl:

set b64 [::base64::encode $mySubject]

New Member

Cisco TCL Other Language support

Hello Joseph, thonk you.

I try do construction like this:

set line_b64 [::base64::encode $line]

set mail_pre "Mailservername: user:pass@smtp.server.com\n"

append mail_pre "From: mail@domain.com\n"

append mail_pre "To: tomail@domain.com\n"

append mail_pre "Cc: from@domain.com\n"

append mail_pre "Subject:test\n"

append mail_pre "Date: $syslog_time_s\n"

append mail_pre "MIME Version: 1.0 \n"

append mail_pre "Content-Type: text/plain\n"

append mail_pre "Content-Transfer-Encoding: Base64\n"

append mail_pre "$line_b64\n"

set mail_msg [uplevel #0 [list subst -nobackslashes -nocommands $mail_pre]]

In email I see line in b64 no cirilic format.

Cisco Employee

Cisco TCL Other Language support

You're not doing what the article says to do.  I'm not sure what you're trying to accomplish here.  If you want to have a subject with Cyrillic characters, do:

...

append mail_pre "Subject: =?UTF-8?B?[::base64::encode Информация]?=\r\n"

...

New Member

Cisco TCL Other Language support

Thank you Joseph. In my case if I use =?UTF-8?B?[::base64::encode Информация]?=\r\n"

It not work in Microsoft Outlook, but work on other (like iphone)

If i use WIN-1251 charset it fork fine in Outlook.

"Subject: =?windows-1251?B?[::base64::encode Информация]?=\r\n"

New Member

Cisco TCL Other Language support

Can posable change charset  for email body?

In subject all ok, in email body i have no readeble value.

I use construction now?

 

set mail_pre "Mailservername: user:pass@smtp.server.com\n"

append mail_pre "From: mail@domain.com\n"

append mail_pre "To: tomail@domain.com\n"

append mail_pre "Cc: from@domain.com\n"

append mail_pre "Subject: =?windows-1251?B?[::base64::encode Информация

]?=\r\n"

append mail_pre "Date: $syslog_time_s\n"

append mail_pre "=?windows-1251?B?[::base64::encode Информация]?=\r\n"

set mail_msg [uplevel #0 [list subst -nobackslashes -nocommands $mail_pre]]

Cisco Employee

Cisco TCL Other Language support

Here is where you need additional headers to specify the MIME encoding.  For example:

append mail_pre "MIME-Version: 1.0\r\n"
append mail_pre "Content-Type: text/plain; charset=\"UTF-8\"\r\n"

New Member

Cisco TCL Other Language support

Thank you Joseph.

841
Views
0
Helpful
7
Replies
CreatePlease to create content