Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 12-11-2011, 08:08 PM   #1
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 425
Blog Entries: 28

Rep: Reputation: 2
decode a non latin character string utf8

Hi, I am not sure how to say this, but when I fetch emails, and the attachment filenames are in chinese, the filenames are not correctly displayed:
So the file extension and the proper name is lost. But when I try to send this file back to gmail, hotmail..etc, the filename in attachment does display correctly in chinese. I think that suggest this string could be decoded with some sort of function. iconv? I am sorry, but could anyone guide me in the right direction?
Old 12-11-2011, 08:28 PM   #2
Randicus Draco Albus
Senior Member
Registered: May 2011
Location: Hiding somewhere on planet Earth.
Distribution: OpenBSD
Posts: 1,647
Blog Entries: 8

Rep: Reputation: 578Reputation: 578Reputation: 578Reputation: 578Reputation: 578Reputation: 578
In addition to utf8, you may need to add big5. I have both installed on my Debian system (which you are apparently using) and I have no problems with displaying Chinese characters.
Is it safe to assume you have either IBus or SCIM installed? If so, just added extra Chinese input methods.
I do not know if it is necessary to add Chinese to the locales, but if you have not already done so, it would not hurt.
I hope that helps.

Last edited by Randicus Draco Albus; 12-11-2011 at 08:29 PM.
1 members found this post helpful.
Old 12-12-2011, 09:26 AM   #3
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 425
Blog Entries: 28

Original Poster
Rep: Reputation: 2
Hi, thanks for the information, but I am not sure if it is actually the input, the here is the top part of the email file:
From .com  Fri Nov 25 08:24:05 2011
Return-Path: <>
Received: from nas (localhost [])
	by nas (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id pAPFNwjF007969
	for <root@localhost>; Fri, 25 Nov 2011 08:23:59 -0700
Received: from []
	by nas with POP3 (fetchmail-6.3.9-rc2)
	for <root@localhost> (single-drop); Fri, 25 Nov 2011 08:23:59 -0700 (MST)
Received: by with SMTP id u12cs217593weh;
        Fri, 25 Nov 2011 07:14:59 -0800 (PST)
Received: by with SMTP id k19mr7429387anh.163.1322234096872;
        Fri, 25 Nov 2011 07:14:56 -0800 (PST)
Received: from ( [])
        by with ESMTPS id w20si9054227and.192.2011.
        (version=TLSv1/SSLv3 cipher=OTHER);
        Fri, 25 Nov 2011 07:14:56 -0800 (PST)
Received-SPF: pass ( domain of designates as permitted sender) client-ip=;
Authentication-Results:; spf=pass ( domain of designates as permitted sender); dkim=pass (test mode)
Received: by qadb12 with SMTP id b12so3401151qad.9
        for <>; Fri, 25 Nov 2011 07:14:56 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=gamma;
MIME-Version: 1.0
Received: by with SMTP id fx2mr10381628obc.31.1322234095924;
 Fri, 25 Nov 2011 07:14:55 -0800 (PST)
Received: by with HTTP; Fri, 25 Nov 2011 07:14:55 -0800 (PST)
Date: Fri, 25 Nov 2011 08:14:55 -0700
Message-ID: <>
From: <>
Content-Type: multipart/mixed; boundary=f46d04446a6798f7a904b2909dff

Content-Type: multipart/alternative; boundary=f46d04446a6798f7a504b2909dfd

Content-Type: text/plain; charset=ISO-8859-1

Content-Type: text/html; charset=ISO-8859-1


Content-Type: application/octet-stream; 
Content-Disposition: attachment; 
Content-Transfer-Encoding: base64
X-Attachment-Id: f_gvfc0wzs0

The line is "=?Big5?B?pmu3Uafvs3mkSKfvwsMgT1ZBKDEtNrawp7kpLnRvcnJlbnQ=?=". I wonder what encode format is this? I tried base64, its not.
Old 12-12-2011, 02:54 PM   #4
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 425
Blog Entries: 28

Original Poster
Rep: Reputation: 2
Thanks to this:
This php script:
$sub="=?UTF-8?B?". base64_encode($sub)."?=";
I wonder if there are packages specialized in decoding strings of base64 in bash? can anyone suggest me?
echo "pECkSKVopdVspPQudHh0" | perl -MMIME::Base64 -ne 'print decode_base64($_)'
might also find this useful:

Last edited by ted_chou12; 12-12-2011 at 03:31 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
get value in character string Abid Malik Programming 1 10-23-2010 02:15 AM
How to get length of UTF8 string navinkaus Programming 5 12-23-2008 05:11 AM
Mysql 4-5 migration as well as character set migration from latin1 to utf8? helptonewbie Linux - Server 3 05-15-2008 05:15 AM
Invalid UTF8 string passed to pango_layout_ Curtux Mandriva 0 05-24-2005 07:42 PM
in linux & c/c++: how do I convert an ascii string to utf8 & vice versa? davidh_uk Programming 2 02-06-2005 05:55 PM

All times are GMT -5. The time now is 03:28 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration