×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Can anyone helpme turn a gibrish string into human language?

Can anyone helpme turn a gibrish string into human language?

Can anyone helpme turn a gibrish string into human language?

(OP)
Hi everyon,
Here is my text file :

Quote:


100055,䪰䬬񺐬054-4889012,,,򥮸 (south),并쬲8,78390,,,erans@hotmail,
102958,򮩬,񺙾󜀸-6418346,052-3964300,,⡸ 񡲠(south),⪺-񠯬35/2,84812,,,amiliv@hotmail,
Here is my code:

CODE -->

<?php
	$myText = 'test_gibrish.txt';
	$myHandle = fopen($myText,'r');
	$myRead = fread($myHandle, filesize($myText));
	$enc = mb_detect_encoding($myRead, "UTF-8,ISO-8859-1");
	$textArr = explode(',',$myRead);
	$str = $textArr[15];
	echo $str."<br>";
	echo iconv($enc, "ISO-8859-1", $str)."<br />";
	echo iconv($enc, "utf-8", $str)."<br />";
	echo iconv($enc, "utf-8", $str)."<br />";
	echo iconv($enc, "ISO-8859-1//TRANSLIT", $str), PHP_EOL;
	echo iconv($enc, "ISO-8859-1//IGNORE", $str), PHP_EOL;
	echo iconv($enc, "ISO-8859-1", $str), PHP_EOL;
	echo $str.'<br>';
?> 
My output shows either gibrish or errors as shown in the attachment
Any advise how to get rid of gibrish from my text file?
Thanks

RE: Can anyone helpme turn a gibrish string into human language?

If it is Unicode gibberish (or Chinglish) to start with, ... the chances are that it WILL be ASCII/Unicode gibberish no matter what you try to do with it.

Is it something vital?

is it UTF-8?
or
Is it UTF-16 and missing the Byte Order Marker?




Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: Can anyone helpme turn a gibrish string into human language?

Looking at the string, it seems to be comma separated values with some special characters that got lost somewhere along the way and are now just ???? (question marks).

What exactly produced this?

If it lost some data at some point, there will be no way to get coherent data out of this.

You may need to alter whatever is producing this output to preserve the special characters.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

RE: Can anyone helpme turn a gibrish string into human language?

the difficulty with deciphering this is that there has already been a broken transformation to utf8 by both the delivery of this page to the browser but also the uploading of the text to the TT servers and probably the storing of the data in the database.

if you get us the actual original text as received by you; and you can tell us the charset of the method used to send you the data, and that of the page (if via web) then there's a fighting chance of recasting to the original chinese characters.

once you have the bytes, split them out into the values between the commas and then attempt a decode. something like this might work

CODE

echo iconv(mb_detect_encoding($text, mb_detect_order(), true), "UTF-16", $text); 

or if you don't support UTF16 try UTF8 but that may not be rich enough to show the chars anyway,

RE: Can anyone helpme turn a gibrish string into human language?

(OP)
This is rather important to me.
It is a backup from SQLServer2005 database I exported to a text file 6 years ago on a XP platform.
Now I want to transfer it into a MySql database but some text became giberish in a WIN 7 platform or in a different machine.
Some thing important about that text is that if I copy a giberish string from the text file and paste it directly into the code it does show me the original string !!!

RE: Can anyone helpme turn a gibrish string into human language?

Does it look okay in the original text file.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: Can anyone helpme turn a gibrish string into human language?

(OP)
The original file is OK except the gibberish fields.
At the beginning, if I copied/pasted the gibberish strings from the text file into the code page, I recieved the desired string but when I read it directly from the text file it remained gibberish.
I changed "encoding" of both code and text file and now copy/paste doesn't work as either.

RE: Can anyone helpme turn a gibrish string into human language?

probably you messed up harmonising the encoding of the connection between the application and the database and the table at the moment that you wrote the data to the table. unless you get them all the same, and all dense enough to take the intended content, you've probably lost the data.

RE: Can anyone helpme turn a gibrish string into human language?

(OP)
Could be...

RE: Can anyone helpme turn a gibrish string into human language?

Quote (lupidol)

Some thing important about that text is that if I copy a giberish string from the text file and paste it directly into the code it does show me the original string !!!

In what program are you viewing the gibberish? Try a different text editor.

Quote (lupidol)

...if I copied/pasted the gibberish strings from the text file into the code page, I recieved the desired string but when I read it directly from the text file it remained gibberish.

Can't you just copy everything and save as a new file?

RE: Can anyone helpme turn a gibrish string into human language?

(OP)
To simplify, I copied one string: 'àôøéí' into a new text file which I named: "xxx.txt" and saved as "utf-8".
Then I copied/pasted the string into the following code:

CODE --> php

<?php
	$myText = 'xxx.txt';
	$myHandle = fopen($myText,'r');
	$myRead = fread($myHandle, filesize('xxx.txt'));
	$enc = mb_detect_encoding($myRead, "UTF-8,ISO-8859-1");
	$textArr = explode(',',$myRead);
	$str = $textArr[0];
	
	echo iconv("UTF-8", "ISO-8859-1", "àôøéí")."<br />";
	echo iconv($enc, "ISO-8859-1", $str)."<br />";
	echo iconv($enc, "utf-8", $str)."<br />";
	echo iconv($enc, "ISO-8859-1//TRANSLIT", 'àôøéí'), PHP_EOL;
	echo iconv($enc, "ISO-8859-1//IGNORE", $str), PHP_EOL;
	echo iconv($enc, "ISO-8859-1", $str), PHP_EOL;
	echo iconv($enc, "ISO-8859-1", 'àôøéí')."<br />";
	echo iconv($enc, "UTF-8", 'àôøéí')."<br />";
	echo iconv($enc, "ISO-8859-1//TRANSLIT", 'àôøéí')."<br />", PHP_EOL;
	echo iconv($enc, "UTF-8", 'àôøéí')."<br />", PHP_EOL;
	echo iconv('UTF-8', "ISO-8859-1", 'àôøéí')."<br />", PHP_EOL;
?> 
The result I got is as shown in the attaches screenshot. Thank you !

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close