English 中文(简体)
Convert latin1 to UTF8
原标题:Convert latin1 to UTF8
  • 时间:2011-03-08 12:19:26
  •  标签:
  • php
  • mysql

我有一个行文——附有表格条款。

I want to convert the title, and content field to utf8 now - all data looks like this: פורטל רעל נפתח רשמית! I want it to become normal hebrew characters.

增 编

最佳回答

你可以从这一数据库中抽取我的原木。 随后下载了“Notepad++”、露天倾销文档、将其转换为“UTF8”,然后通过档案把所有编码替换到包括第一家“SET 不结盟运动”运营商在内的utf-8。

如果您通过phpMyAdmin(在缺省的情况下)进行倾销,则使用输出档案,编码ISO-8859-1而不是UTF-8,因为你可以默认。

问题回答

在双重编码后,MySQL的以下功能将恢复正确的直观8:

CONVERT(CAST(CONVERT(field USING latin1) AS BINARY) USING utf8)

可以通过一份最新资料加以利用,纠正以下领域:

UPDATE tablename SET field = CONVERT(CAST(CONVERT(field USING latin1) AS BINARY) USING utf8);

if you need to convert the whole database , you can back it as databaseback.sql file then form your command line iconv -f latain -t utf-8 < databaseback.sql > databaseback.utf8.sql

you can use the http://www.php.net/manual/en/function.iconv.php
to convert each row in php in case you don t have command line access

最后,不要忘记改变在“Sandmyadmin”的每一个领域之间的串通,那么,你可以轻易地将“utf8”退回。

<>>>>

如果您没有被承认为,这意味着你没有<条码>。 安装

much more easier solution is : Migrating MySQL Data to Unicode

http://daveyshafik.com/archives/166-migration-mysql-data-to-unicode.html>

您可以撰写少量的、与转换成正文的文稿。 See http://www.php.net/manual/en/Function.mb-detect-encoding.php and

http://www.php.net/manual/en/Function.mb-detect-encoding.php#102510"rel=“nofollow”http://www.php.net/manual/en/Function.mb-detect-encoding.php#102510

在假体编码中,这种说法是荒谬的。 类似:

str = getDataAsString()
if(!isUTF8(str)) {
  str = convert2UTF8(str)
}
saveStr2DB()

审判

ALTER TABLE `tablename` CHANGE `field_name` `field_name` VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL 




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签