LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 12-11-2011, 09:08 PM   #1
ted_chou12
Member
 
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 421
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:
Code:
=?Big5?B?pmu3Uafvs3mkSKfvwsMgT1ZBKDEtNrawp7kpLnRvcnJlbnQ=?=
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?
Thanks,
Ted
 
Old 12-11-2011, 09:28 PM   #2
Randicus Draco Albus
Senior Member
 
Registered: May 2011
Location: Hiding somewhere on planet Earth.
Distribution: OpenBSD
Posts: 1,644
Blog Entries: 8

Rep: Reputation: 577Reputation: 577Reputation: 577Reputation: 577Reputation: 577Reputation: 577
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 09:29 PM.
 
1 members found this post helpful.
Old 12-12-2011, 10:26 AM   #3
ted_chou12
Member
 
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 421
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:
Code:
From .com  Fri Nov 25 08:24:05 2011
Return-Path: <@gmail.com>
Received: from nas (localhost [127.0.0.1])
	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
Delivered-To: 
Received: from gmail-pop.l.google.com [74.125.53.109]
	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 10.216.123.12 with SMTP id u12cs217593weh;
        Fri, 25 Nov 2011 07:14:59 -0800 (PST)
Received: by 10.100.237.19 with SMTP id k19mr7429387anh.163.1322234096872;
        Fri, 25 Nov 2011 07:14:56 -0800 (PST)
Received: from mail-qw0-f50.google.com (mail-qw0-f50.google.com [209.85.216.50])
        by mx.google.com with ESMTPS id w20si9054227and.192.2011.11.25.07.14.56
        (version=TLSv1/SSLv3 cipher=OTHER);
        Fri, 25 Nov 2011 07:14:56 -0800 (PST)
Received-SPF: pass (google.com: domain of designates 209.85.216.50 as permitted sender) client-ip=209.85.216.50;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of @gmail.com designates 209.85.216.50 as permitted sender) smtp.mail=@gmail.com; dkim=pass (test mode) header.i=@gmail.com
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;
        d=gmail.com; s=gamma;
        h=mime-version:date:message-id:subject:from:to:content-type;
        bh=d95Vwe9KGaQe4rC3Qhr/8HGjNu+W/peleuKyjiIGYe4=;
        b=WXYViW1/GCZXqlevDB6Ji175FDGzStJIObQpuprhANjqBYANh3q11mBfOnjtXJoKSu
         ntHaOlOMCgSDb/Hwn4/pSz5RobLOTZiZCNZj8N1eGuZMAx81rUrbiVSp9aIjw1sWdsZY
         dkaOKE4Z+NPw7/Xb0lye0ib8Y5qtdNPcjEP3E=
MIME-Version: 1.0
Received: by 10.182.188.34 with SMTP id fx2mr10381628obc.31.1322234095924;
 Fri, 25 Nov 2011 07:14:55 -0800 (PST)
Received: by 10.182.122.9 with HTTP; Fri, 25 Nov 2011 07:14:55 -0800 (PST)
Date: Fri, 25 Nov 2011 08:14:55 -0700
Message-ID: <CAG4-7shs5rP1puNq0z4WqYsy05Jw2PTR+hNq616AJcKxgBrhMQ@mail.gmail.com>
Subject: 
From: <@gmail.com>
To: 
Content-Type: multipart/mixed; boundary=f46d04446a6798f7a904b2909dff

--f46d04446a6798f7a904b2909dff
Content-Type: multipart/alternative; boundary=f46d04446a6798f7a504b2909dfd

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



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

<br>

--f46d04446a6798f7a504b2909dfd--
--f46d04446a6798f7a904b2909dff
Content-Type: application/octet-stream; 
	name="=?Big5?B?pmu3Uafvs3mkSKfvwsMgT1ZBKDEtNrawp7kpLnRvcnJlbnQ=?="
Content-Disposition: attachment; 
	filename="=?Big5?B?pmu3Uafvs3mkSKfvwsMgT1ZBKDEtNrawp7kpLnRvcnJlbnQ=?="
Content-Transfer-Encoding: base64
X-Attachment-Id: f_gvfc0wzs0

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

Original Poster
Rep: Reputation: 2
Thanks to this:http://cgi.blog.roodo.com/comment#commentForm
This php script:
Code:
$sub="中文字碼";
$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?
Thanks,
Ted
GOT IT:
Code:
echo "pECkSKVopdVspPQudHh0" | perl -MMIME::Base64 -ne 'print decode_base64($_)'
might also find this useful:
http://codebase.tuxnet24.de/index.ph...19&snippets=23
Thanks,

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


Reply


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 03:15 AM
How to get length of UTF8 string navinkaus Programming 5 12-23-2008 06:11 AM
Mysql 4-5 migration as well as character set migration from latin1 to utf8? helptonewbie Linux - Server 3 05-15-2008 06:15 AM
Invalid UTF8 string passed to pango_layout_ Curtux Mandriva 0 05-24-2005 08:42 PM
in linux & c/c++: how do I convert an ascii string to utf8 & vice versa? davidh_uk Programming 2 02-06-2005 06:55 PM


All times are GMT -5. The time now is 06:33 AM.

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