I'm using https://github.com/farjadtahir/pdf-invoicr.
Problem is when I add diacritics to $invoice->setFrom() (or anywhere else) diacritics not showing up.
I tried $invoice->setFrom(array(iconv("UTF-8", "ISO-8859-1","ÆØÅ")from this comments
but still diacritics not working.
Next I tried https://stackoverflow.com/a/21555497/2893691 again not working.
So, how to finally convert ľščťžýáíé to UTF-8 in invoicr?
EDIT - NEW INFO
I'm used mb_detect_encoding() and return is UTF-8 already. But when I try show for example string ičo123 the result is empty. Not showing.
I tried add header('Content-Type: text/html; charset=utf-8'); and still diacritics not working.
EDIT 2 - NEW INFO
I tried this script http://www.fpdf.org/en/script/script92.php and still not working. Here is screenshot of downloaded example from link above:
Problem solved - Used script from EDIT 2 and removed all iconv() functions from phpinvoice.php file.
Related
This question already has answers here:
UTF-8 all the way through
(13 answers)
Closed 7 years ago.
I've looked at all the relevant topics on the site and this particular gotcha does not seem to be covered
I exported a Word 2016 document (in French) as filtered HTML ( filtered= no office specific stuff included). If I show the file in my browser as html, everything is fine - all the accents show correctly. ( Charset is utf-8 and it's not coming from a database). But when I change the extension to .php and run it, all the french characters are shown as black diamonds with a question mark inside.
If I express the french characters as html entities, they show correctly, but I don't want to do this as the fix - there are hundreds of them in there, and I don't want to edit the text - it's not mine and the author would have to proof read it all again just to check the accents.
So I figured it's a PHP (5.5.26) issue - but I can't see anything in the ini file which might affect this - it looks like UTF-8 is the default charset if you don't change anything,
What's the fix ??
If this is a problem with just one file, you can use the following:
<?php
header('Content-Type: text/html; charset=iso-8859-1');
?>
On the html part add or change:
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1 />
If you've thousands of files and you don't want to change them manually you can try to modify the following line on your php.ini:
default_charset = "utf-8"
to
default_charset = "iso-8859-1";
Save and restart the server.
QUESTION:
Hello stackoverflow!
So this encoding stuff is getting on my last nerve. Not enough that it is difficult to figure out what the best combination of encodings needs to be when sending stuff forth and back using AJAX and PHP and SQL etc.. But it also causing problems with SESSION???!
So basically I already found a hot-fix solution no-thanks to google, partly the reason I'm writing this now. But I would also like to see if anyone of you actually have any more practical solution.
PROBLEM:
For example if I want my PHP file to have UTF-8 encoding, it then adds hidden characters in the file which then can only be viewed and deleted in a hex-editor. For those that don't know, YES any extra characters that aren't commented out will cause problems with SESSION and give you header error. So when I delete them, and re-upload the file, it falls back to ANSI encoding. Maybe there are different editors that can encode files more properly into UTF-8? I don't know, I'm using Notepad++ at the moment and am perfectly happy with it and it is hard to believe it should cause problems with encoding. I have also tried to change my default encoding in .htaccess file and no difference for the index file anyways.
It seems, although we get WARNING: session_start(): Cannot send session cache limiter - headers already sent ... the sessions are still set perfectly fine and all we could do at this point is simply turning off warning errors by placing this on top of our php file: error_reporting(~E_NOTICE & ~E_WARNING); although this doesn't really solve our problem and simply hiding it from public eye.
Page open Notepad2 or Sublime Text -> Save with Encoding -> UTF-8
index.php
<?php
session_start();
header('Content-type: text/html; charset=utf-8');
echo 'Hello ÇÖİŞÜĞüğışçö'; // bla bla
?>
SOLUTION:
I had to therefore make a fix by making 2 separate files for one and the same index, just with different encoding. Like my main file is ANSI encoded and called
index.php
that will have session_start(); line in it and beneath it we include our main scripts that were originally supposed to be there, but instead now included with this include('index_.php'); ................ Also I found out that this problem will NOT occur on all hosting servers, but only some. So the real solution may be found trough somewhere in the server settings.
I am currently moving blog posts from wordpress to drupal. however after moving it
some of the text is not being displayed correctly.
wordpress is displaying :
When it hasn’t (html code is <h2>When it hasn’t</h2>)
Drupal is displaying :
When it hasn’t (html code is <h2>When it hasn’t</h2>)
In the wordpress and drupal db the value is correct. The source is the same.
<h2>When it hasn’t</h2>
I did a search and found many options. None of them helped.
Below are the ones I have done and checked.
1) I double checked that utf-8 is the character encoing in drupal and wp.
I also made a simple test.php file to check nothing else was coming in the way
and it still did not display correctly.
2) I made sure when we take a mysqldump and upload to drupal utf-8
is used.
3) I also made sure the .php file is in utf-8 when saved.
4) I changed the encoding type in chrome for every option available and nothing
displayed it correctly.
5) I also used php functions to recode it but they did not work.
$value2="<h2>When it hasn’t</h2>";
$out = recode_string('..utf-8', $value2);
//output - When it hasnt
$out2= mb_convert_encoding($value2,'UTF-8', "UTF-8");
// output - When it hasn’t
$out3= #iconv('UTF-8', 'utf-8', $value2);
// output - When it hasn’t
I have ran out of options now and I am stuck. Please help
You say the text in both databases is correct, but actually this doesn't mean too much: to viewing the content of a record you must use some client, and quite a few transformations may happen depending on how the text is rendered so you can read it.
So only two things matters:
the encoding of the column
the encoding of the HTML page returned by Drupal
Since your page outputs ’ (in CP1252 is xE2x80x99) for ’ (Unicode U+2019, UTF-8 is 0xE28099) I guess the column is indeed UTF-8, however there's someone between the database and the browser who thinks the text is CP1252. This is what you have to check:
If using MySQL, the connection encoding must be UTF-8 so that what you have in your PHP script is UTF-8 text. You can use SET NAMES 'UTF-8'. Note that if you don't need the Unicode set, you can even use CP1252: the only important thing is that you know the encoding, since PHP strings are just byte arrays.
Explicitely define the response encoding in the HTTP Content-Type header. I mean, configure Drupal to call header('Content-Type: text/html; charset=utf-8');
If the HTTP response encoding is different than the one used for the text retrieved from the db, transcode the query result accordingly
When navigating to a URL like this:
http://example.com/user?u=ヴィックサ
I notice that Chrome encodes the characters as:
http://example.com/user?u=%E3%83%B4%E3%82%A3%E3%83%83%E3%82%AF%E3%82%B5
And everything works serer-side.
However, in IE I get this error from my code:
The user you are trying to find (?????) does not exist.
Note the five question marks. For some reason the PHP never gets to see the parameter.
What could be causing this, and is there any way to fix it?
Sadly it seems what you want to do is not going to work for the current generation of IE
The accepted answer for this question UTF-8 Encoding issue in IE query parameters says that you need to encode the characters yourself rather than relying on the browser as support varies from browser to browser, and maybe even device to device
<a href='/path/to/page/?u=<?=urlencode('ヴィックサ')?>'>View User</a>
Also I presume you are setting utf8 headers from the webserver? you didn't say, if not, in php
header('Content-Type: text/html; charset=utf-8');
I have a trouble displaying Cyrillic characters properly. Looked in forums, tried a few different thing and nothing works.
Site runs on PHP / MySQL.
MySQL tables charset is utf8, and collation is utf8_general_ci
Name entry in DB looks correct (in PhpmyAdmin):
Sasha Рукина
Output on page http://www.sodaq.com/: Sasha ??????
Inside PHP I use:
mb_internal_encoding("UTF-8");
mb_http_output("UTF-8");
And send HTTP header 'Content-type: text/html; charset=utf-8'
Still, shows '????' instead of normal characters.
Please help.
try to execute the following query before loading your data
SET NAMES 'utf8';
Have you also tried:
set character_set_connection=utf8;
You didn't mention the font you're using, but it's a big factor. Not all fonts contain all character sets.