UTF8 problem
UTF8 problem
Hi guys,
I am doing some data scraping and storing the data into MYSQL database.
The field in question is set in MYSQL to UTF8.
I get the following data into the database as
<div class="panel marTop20">
<h3>Technical Specs</h3>
<p>No Load Speed: 2,500-4,200/min.<br>Depth of Cut: @90º: 59mm, @45º: 44mm.<br>With Guide Rails: @90º: 55mm, @45º: 40mm.<br>Blade: 165x20mm Bore<br>Bevel Capacity: 47<br>Weight: 4.7kg</p>
</div>
but the ' deg o' is shown as ' º '
I have tried using decodeURIComponent(escape) in the render but I get error 'URIError: URI error.'
my php is
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
$quoteID = $_GET["quoteID"];
/*
* Example PHP implementation used for the index.html example
*/
// DataTables PHP library
include( "DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'products3','productID' )
->fields(
Field::inst( 'products3.productID' )->set(false),
Field::inst( 'products3.manufacturerCode' ),
Field::inst( 'products3.TBcost' ),
Field::inst( 'products3.TBmyCost' ),
Field::inst( 'products3.CTSmyCost' ),
Field::inst( 'products3.tradeNett' ),
Field::inst( 'products3.trade' ),
Field::inst( 'products3.retail' ),
Field::inst( 'products3.TBstockCode' ),
Field::inst( 'products3.barCode' ),
Field::inst( 'products3.shortDesc' ),
Field::inst( 'products3.longDesc' ),
Field::inst( 'products3.category' )
->options( Options::inst()
->table( 'categories2' )
->value( 'catID' )
->label( 'name' )
)//,
//Field::inst( 'categories2.name' )
)
->join(
Mjoin::inst( 'fileDetails' )
->link( 'products3.productID', 'productFiles.productID' )
->link( 'fileDetails.id', 'productFiles.fileID' )
->fields(
Field::inst( 'filename' ),
Field::inst( 'web_path' ),
Field::inst( 'id' )
->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/upload/__ID__.__EXTN__')
->db( 'fileDetails', 'id', array(
'filename' => Upload::DB_FILE_NAME,
'filesize' => Upload::DB_FILE_SIZE,
'web_path' => Upload::DB_WEB_PATH,
'system_path' => Upload::DB_SYSTEM_PATH
) )
->validator( function ( $file ) {
return$file['size'] >= 10000000 ?
"Files must be smaller than 10 meg" :
null;
} )
//->allowedExtensions( array( 'png', 'jpg' ), "Please upload an image" )
)
)
)
//->leftJoin( 'sites', 'sites.id', '=', 'products3.site' )
->process( $_POST )
->json();
I also tried adding this to the bootstrap.php file.
```php
$db->sql("SET character_set_client=utf8");
$db->sql("SET character_set_connection=utf8");
$db->sql("SET character_set_results=utf8");
````
How do I handle this issue please.
Cheers
Steve Warby
Answers
Path is Editor-PHP-.../php/config.php In that file you'll find this:
Mine looks like this - and I have no problem with utf8.
I ran into a similar issue when I built my own PDO PHP class based on this example: http://culttt.com/2012/10/01/roll-your-own-pdo-php-class/
The example has this statement which doesn't work for UTF8:
I replaced it with this and it has been working fine ever since:
Thanks for the help.
I have added "dsn" => "charset=utf8" but I still get the same issue.
Cheers
Steve Warby
Steve, I tried it myself entered "90°" into a VARCHAR field in one of my tables and it worked out fine.
The table has the collation "utf8 - utf8_unicode_ci". The column has character set "utf8" and collation "utf8_unicode_ci".
Maybe you want to check your Mysql table and column definitions?!
You could also try adding:
before your initialise the Editor instance in the PHP.
Allan
Hi Guys,
I am still having an issue.
I am using the following code config.php
anims.php
config for the table attached.
I have the following manually entered into the field
When viewed in the editor ( set to CKEditor) I see the video okay.
When I update via the editor the following is stored in the table.
As a work around I create what I need using editor & CKEditor then select the source code and manually paste into the table.
What am I not understanding or missing here ?
Cheers
Steve Warby
Right - that's a different issue. Its encoded HTML Entities for XSS protection. See this section of the Editor manual for details and how to turn it off.
Allan