Hướng dẫn base64 decode utf8 php

Is there any way to decode this string??

Actual string : 其他語言測試 – testing

base64 encode while sending on mail as subject as

“=?iso-2022-jp?B?GyRCQjZCPjhsOEBCLDtuGyhCIC0gdGVzdGluZw==?=”

<?php echo base64_decode(“GyRCQjZCPjhsOEBCLDtuGyhCIC0gdGVzdGluZw==”); ?>

This is base 64 encode, I couldn”t decode it to actual Chinese string.Since it has been encoded using “iso-2022-jp”, I have also tried online base64decode.org site to decode this string, but I couldn”t find the original string, how can I do that?

Đang xem: Base64 decode php utf8

php base64
Share
Improve this question
Follow
edited Jul 26 “16 at 12:57
NavidIvanian
351 5 5 silver badges 14 14 bronze badges
asked Sep 17 “13 at 5:42
thukthuk
243 3 3 gold badges 6 6 silver badges 18 18 bronze badges
3
1
Have you tried mb_convert_encoding? mb_convert_encoding(base64_decode($str)); – Steven Liao Sep 17 “13 at 5:46
This is my result: 5YW25LuW6Kqe6KiA5ris6KmmIC0gdGVzdGluZw== and while I decoded I get 其他語言測試 – testing but when tested yours I can't see original text – Jason OOO Sep 17 “13 at 5:47
Steven Liao i tried the following result: ??-?x – thuk Sep 17 “13 at 5:52
Add a comment  | 

  • 3 Answers 3
  • Not the answer you're looking for? Browse other questions tagged php base64 or ask your own question.

3 Answers 3

Active Oldest Votes
13

Use iconv():

<?php $input = base64_decode(“GyRCQjZCPjhsOEBCLDtuGyhCIC0gdGVzdGluZw==”);//$BB6B>8l8
B,;n(B – testing $input_encoding = “iso-2022-jp”; echo iconv($input_encoding, “UTF-8”, $input); //其他語言測試 – testing ?>
Share
Improve this answer
Follow
answered Sep 17 “13 at 5:52
Jason OOOJason OOO
3,437 2 2 gold badges 21 21 silver badges 28 28 bronze badges
1
1
is there a way to find the what is encoding format by giving this string as input ; – thuk Sep 17 “13 at 5:59
Add a comment  | 
2

What you are looking at is MIME header encoding. It can be decoded by mb_decode_mimeheader(), and generated by mb_encode_mimeheader(). For example:

<?php mb_internal_encoding(“utf-8”); $subj = “=?iso-2022-jp?B?GyRCQjZCPjhsOEBCLDtuGyhCIC0gdGVzdGluZw==?=”; print mb_decode_mimeheader($subj); ?> 其他語言測試 – testing

(The call to mb_internal_encoding() is necessary here because the contents of the subject line can”t be represented in the default internal encoding of ISO8859-1.)

Share
Improve this answer
Follow
edited Sep 17 “13 at 6:17
answered Sep 17 “13 at 6:12
duskwuff -inactive-duskwuff -inactive-
169k 27 27 gold badges 215 215 silver badges 267 267 bronze badges
0
Add a comment  | 
1

Try encoding the string to UTF-8 first and then encode it to base 64. Same when decoding, decode the string from base64 and then from UTF-8. This is working for me:

php > $base = “其他語言測試 – testing”; php > $encoded = base64_encode(utf8_encode($base)); php > $decoded = utf8_decode(base64_decode($encoded)); php > echo ($decoded === $base) . ”
“; 1
Share
Improve this answer
Follow
answered Sep 17 “13 at 5:48
Daniel PerezDaniel Perez
4,143 1 1 gold badge 19 19 silver badges 25 25 bronze badges
1
i am not converting it, when i send mail using outlook and subject to chineses character, when i read the stream i am getting like this, so how to decode it, that is present in iso-2022-jp format? – thuk Sep 17 “13 at 5:54
Add a comment  | 
Highly active question. Earn 10 reputation in order to answer this question. The reputation requirement helps protect this question from spam and non-answer activity.

Not the answer you're looking for? Browse other questions tagged php base64 or ask your own question.

The Overflow Blog
Infrastructure as code: Create and configure infrastructure elements in seconds
Podcast 318: What’s the half-life of your code?
Featured on Meta
Introducing Outdated Answers project
Survey questions for outdated answers
Linked
0
Encrypt PHP query string value in URL
2
how to decode the encoded php file in
Related
2773
How can I prevent SQL injection in PHP?
910

Xem thêm: Phần Mềm Krpano 1 – Reviews, Tính Năng, Bảng Giá, So Sánh

How can you encode a string to Base64 in JavaScript?
2694
Deleting an element from an array in PHP
499
Decode Base64 data in Java
4675
Reference — What does this symbol mean in PHP?
2660
How do I check if a string contains a specific word?
932
How to do Base64 encoding in node.js?
1016
How do I encode and decode a base64 string?
1183
Reference – What does this error mean in PHP?
2564
Why shouldn't I use mysql_* functions in PHP?
Hot Network Questions
overful hbox . Someone could explain once for all?
Why atoms arrange themselves in a regular fashion to form crystal?
What is the rigorous definition of the verb "to quantize"?
Superman comic book with an alien villain who was frozen and dumped in deep space, rather than being executed
Is it okay to give students advice on managing academic work?
Why can't the Earth's core melt the whole planet?
How can I raise my handlebars when there are no spacers above the stem?
Conceptual difficulty with friction and inertia
What does "bipartisan support" mean?
Why use 5 or more ledger lines below the bass clef instead of ottava bassa lines for piano sheet music?
Does Jnana marga takes much time compared to Karma and Bhakti?
As a DM, is telling your players what their characters conclude a bad practice?
Defi-Staking is it 100% safe?
How exactly did engineers come to the final design of jets like the F-16 or SR-71?
How could a lost time traveller quickly and quietly determine they've arrived in 500 BC France?
Does the Rubik's Cube in this painting have a solved state?
Is there a broader term for instruments, like the gong, whose volume briefly increases after being sounded instead of immediately decaying?
Can I keep playing a character who annoys other PCs?
Meaning of "The blushing apricot, and woolly peach. Hang on thy walls, that every child may reach."
Late 80's game, post apocalyptic dinosaurs and guns
How do I tilt a lens to get an entire street in focus?
I may have to write a bad recommendation for an underperforming student researcher in the Fall. How to avoid this without being exploitative?
Why is processing an unsorted array the same speed as processing a sorted array with modern x86-64 clang?
Why do airplane indicators start at 12 (o'clock), unlike cars that start at 7? more hot questions
Question feed
Subscribe to RSS
Question feed

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

lang-php
Stack Overflow Questions Jobs Developer Jobs Directory Salary Calculator Help Mobile
Products Teams Talent Advertising Enterprise
Company About Press Work Here Legal Privacy Policy Terms of Service Contact Us
Stack Exchange
Network Technology Life / Arts Culture / Recreation Science Other
Stack Overflow Server Fault Super User Web Applications Ask Ubuntu Webmasters Game Development
TeX – LaTeX Software Engineering Unix & Linux Ask Different (Apple) WordPress Development Geographic Information Systems Electrical Engineering
Android Enthusiasts Information Security Database Administrators Drupal Answers SharePoint User Experience Mathematica
Salesforce ExpressionEngine® Answers Stack Overflow em Português Blender Network Engineering Cryptography Code Review
Magento Software Recommendations Signal Processing Emacs Raspberry Pi Stack Overflow на русском Code Golf
Stack Overflow en español Ethereum Data Science Arduino Bitcoin Software Quality Assurance & Testing Sound Design
Windows Phone more (28)
Photography Science Fiction & Fantasy Graphic Design Movies & TV Music: Practice & Theory Worldbuilding Video Production
Seasoned Advice (cooking) Home Improvement Personal Finance & Money Academia Law Physical Fitness Gardening & Landscaping
Parenting more (10)
English Language & Usage Skeptics Mi Yodeya (Judaism) Travel Christianity English Language Learners Japanese Language
Chinese Language French Language German Language Biblical Hermeneutics History Spanish Language Islam
Русский язык Russian Language Arqade (gaming) Bicycles Role-playing Games Anime & Manga Puzzling
Motor Vehicle Maintenance & Repair Board & Card Games Bricks Homebrewing Martial Arts The Great Outdoors Poker
Chess Sports more (16)
MathOverflow Mathematics Cross Validated (stats) Theoretical Computer Science Physics Chemistry Biology
Computer Science Philosophy Linguistics Psychology & Neuroscience Computational Science more (10)
Meta Stack Exchange Stack Apps API Data
Blog Facebook Twitter LinkedIn Instagram

site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.3.5.38726

Xem thêm: Aha/ Bha Là Gì ? Công Dụng Và Cách Dùng Mỹ Phẩm Bha Hiệu Quả

Stack Overflow works best with JavaScript enabled