?
Solved

how can i detect the encoding of a string?

Posted on 2009-02-16
7
Medium Priority
?
818 Views
Last Modified: 2012-08-14
i have alout of strings in araic and i want to know if eatch string is utf-8 or windows-1256

how can i do this?
0
Comment
Question by:mgtm3
  • 4
  • 3
7 Comments
 
LVL 5

Expert Comment

by:striker46
ID: 23648362
0
 
LVL 5

Expert Comment

by:striker46
ID: 23648383
Or perhaps this is also useful to you
PHP mb_detect_encoding()
http://php.morva.net/manual/en/function.mb-detect-encoding.php 
0
 

Author Comment

by:mgtm3
ID: 23648813
the fist one i dont know how to use it and the second one don't recognize windows-1256

please help
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 5

Expert Comment

by:striker46
ID: 23648843
About the 2nd... why instead of making a condition true when detecting windows-1256, you don't do the other way round and make the condition be true when not detecting utf-8 (and therefore assuming it is detecting windows-1256)?
0
 
LVL 5

Accepted Solution

by:
striker46 earned 2000 total points
ID: 23648865
You can attempt character conversion like



http://us.php.net/manual/en/function.iconv.php


$str = "blah"
 
if(mb_detect_encoding($str) != 'utf-8')
{
    $str = iconv('windows-1256','utf-8', $str);
}  

Open in new window

0
 

Author Comment

by:mgtm3
ID: 23648917
ya the problem is that even if its not utf-8 it says its utf-8
i think because it dose not recognize it than it thinks it is utf-8
0
 

Author Closing Comment

by:mgtm3
ID: 31547258
thankss
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question