जवाबों:
से स्टैक ओवरफ़्लो :
You can get a tool such as iconv from GnuWin32 and run a batch script to process all of your files that way. But what encoding are they now? If they're ANSI, and you're not using any bytes with values => 128, then they're already BOM-less UTF-8. Perhaps you can use that to narrow down the number of files you'd have to process - maybe enough that you only have a few files to convert (and might prefer to do it on an individual basis).
Actually, I do it with Notepad++. Before trying this, you must make a backup of your files. You need to create a macro that does this:अब, अपने को खोलें
- वर्तमान में खोली गई फ़ाइल को UTF-8 w / o BOM में बदलें;
- अपनी फ़ाइल के सभी पाठ का चयन करें, और इसे कॉपी करें (ऐसा क्यों? यह एक बग की तरह दिखता है। यदि आप ऐसा नहीं करेंगे; आपकी फ़ाइल को आपकी वर्तमान क्लिपबोर्ड सामग्री से बदल दिया जाएगा ...);
- वर्तमान फ़ाइल सहेजें;
- वर्तमान फ़ाइल बंद करें।
- इस मैक्रो को बचाओ।
पीएचपीफ़ाइलें, और इसे "एक मैक्रो भागो भागो" के साथ चलाएं टाइम्स ... "कमांड। यदि आपने 100 फाइलें खोली हैं, तो इसे 100 बार चलाने दें।
<?php
$url = getenv("SERVER_ADDR");
//$url = getenv(HTTP_POST_VARS);
$rootdir='d:\\xampp\\htdocs\\ecoder';
$dir=".";
$files=scan_dir($rootdir);
foreach ($files as $file) {
$info = pathinfo($file);
$extF =$info["extension"];
if ($extF == "php" || $extF == "txt" || $extF == "js" || $extF == "css") {
echo $file ."
";
$ डेटा = file_get_contents ($ फ़ाइल);
wrUTF8File ($ फ़ाइल, $ डेटा);
गूंज $ फ़ाइल। ' को UTF8 में बदल दिया गया
';
}
}
// इस फ़ंक्शन का उपयोग एक डायरेक्टरी के अंदर सभी फाइलें प्राप्त करने के लिए (उपनिर्देशिका सहित)
समारोह scan_dir ($ dir) {
$ अरफाइल्स = सरणी ();
अगर (is_dir ($ dir)) {
अगर ($ संभाल = opendir ($ dir)) {
chdir ($ dir);
जबकि (गलत! == ($ फ़ाइल = रेडीयर ($ हैंडल))) {
अगर ($ फ़ाइल! = "" & amp; & amp; $ फ़ाइल! = "" .. ") {
अगर (is_dir ($ फ़ाइल)) {
$ गिरफ्तार = scan_Dir ($ फ़ाइल);
foreach ($ मूल्य के रूप में गिरफ्तार) {
$ अरफाइल्स [] = $ dir। "/"। $ मूल्य;
}
} अन्य {
$ अरफाइल्स [] = $ dir। "/"। $ फ़ाइल;
}
}
}
chdir ( "../");
}
closedir ($ संभाल);
}
$ गिरफ्तारियां लौटाएं;
}
function writeFF8File ($ फ़ाइल नाम, $ सामग्री) {// F F เป็น UTF8
$ F = fopen ($ फ़ाइल नाम, "डब्ल्यू");
# अब UTF-8 - बाइट ऑर्डर मार्क जोड़ें
fwrite ($ f, pack ("CCC", 0xef, 0xbb, 0xbf));
fwrite ($ च, $ सामग्री);
fclose ($ च);
}
? & Gt;