Uploaded Image file name encoding/charset in Wordpress - php

I have a pretty weird problem that I have not faced before, and with a 2-hour search I had no results;
I recently migrated a wordpress site, what I did was;
Export database and import on new server (via phpMyAdmin)
Copy Wordpress client files to new database.
Edit wp-config.php relative to new database information.
Everything was working correctly, but only problem was, in new server some of images that is used in posts or as thumbnails are not showing in browser (probably due to Turkish unsafe chars).
As an example, if I inspect the link of the image, wordpress redirects me to 404 page;
File name: çiğ-beslenme-mi-yoksa-pişirmek-mi.jpg
How wordpress prints it:
wp-content/uploads/2017/01/%C3%A7i%C4%9F-beslenme-mi-yoksa-pi%C5%9Firmek-mi.jpg
How I can access it via browser:
wp-content/uploads/2017/01/c%CC%A7ig%CC%86-beslenme-mi-yoksa-pis%CC%A7irmek-mi.jpg
For example, for the char ç wordpress prints; %C3%A7 and it is accessible with c%CC%A7
As you can see, I can add a c letter before printing ç and change %CC%A7 with %C3%A7 or s before ş, this way, images gets shown again. But I would like to know what is the problem here, or what is the cause of this.
I would love that if there is anyone out there, have a better understanding on charsets illuminate me. I'm positive this would occur with German or Dannish also, since these languages has unsafe latin letters too.
Additional information;
Its a LAMP, no control panel software.
PHP Version 7.0.13-0ubuntu0.16.04.1
Apache/2.4.18 (Ubuntu)
mysqlnd 5.0.12-dev
PHP charset: UTF-8
Charset in mysql tables (?) utf8mb4_unicode_520_ci
If needed I can add more information in demand.

Related

NetBeans Doesn't Display Chinese Content

Good day,
My dev pc env like this,
Win11 and NetBeans16 installed. I am dev PHP Lang now.
When I opened an existing source code folder and I found these Chinese content can't display normally.( Pls see screen capture posted as below)
I already tried several methods as below,
I configured the NetBeans Project Encoding to UTF-8; // doesn't work
I tried to type simple Chinese content in the IDE directly; // Same issue
I googled and modified the 'netbeans.conf' file and added the
-J-Dfile.encoding=UTF-8
at the end of netbeans_default_options=" , and then I restarted my NetBeans or enen I reboot my win OS. The problem is still can't resolve.
BTW,
I could view the Chinese content in Visula Studio Code via my PC.
And I configured my DB encode to UTF-8 Unicode (utf8mb4).
Thks for your suggestions in advance.
Followed Skomisa's suggestion. I solved the issue as below,
I must choose one font that support Chinese character and then I could render it in NetBeans edit window.(as I commented above)
See the result attached.

Cyrillic characters messed up in .php webpage

All my files with .php extension and Cyrillic encoding that worked fine for years got messed up. Probably because of PHP server upgrade by hosting provider.
To illustrate the problem I wrote the simplest possible file which cannot have any errors:
http://reverent.org/testencoding.php
For some reason webpage defaults to unicode when viewed in a browser. If you go to view -> Text encoding and select Cyrillic(Windows) everything gets fine.
In contrast, exactly the same file with .html extension is displayed correctly right away:
http://reverent.org/testencoding.html
Any idea?
Now, I'm no expert on this, but this seriously reminds me of the exact issue I had. So.. personal experience, here goes (I'm sure this might help someone):
My issue was that my files on the server were set to windows 1251 by default instead of UTF-8, which I needed.. this caused these little beasts to appear: � in place of every symbol that wasn't just a basic letter or something like that. Coincidentally this is what your example looks like. And the encoding is the same. I fixed it by accessing the files with WinSCP and just switching the files to UTF-8 manually... ironically your file shows pretty much what I saw on my website.
There must be better ways to do this than WinSCP, but to be honest, this is the only time I've had to do this manually, so this is exactly what I clicked there (after opening the file):
You could also try to fix it with a meta tag to tell the browser which charset to use, but the files might be getting deformed the moment you save them, if their encoding is wrong.
<meta charset="utf-8">
This might not work for you, but it did work for me, so there's hope :)
Hope it helps or at least points you in the right direction :)
I just put the php.ini file with this single line 'default_charset = "windows-1251"' in the directory with the files with Cyrillic encoding. This overwrites server's php.ini which sets default charset to UTF.
Now everything is fine: http://reverent.org/ru/testencoding.php

Wordpress - wp-config.php encoding - erratic behaviour

I'm facing a strange problem with my wordpress multisite installation. I have a couple of domains on the same server and depending on which domain I use to access the same file, I get different results.
When I need to access Wordpress Core from pages outside the usual structure, I use the following code:
require_once("../../wp-config.php");
$wp->init(); $wp->parse_request(); $wp->query_posts();
$wp->register_globals(); $wp->send_headers();
echo "test hello";
The execution of this code works fine with all domains but when using some specific domains, 4 blank lines are added to the top of my page.
So on domain name 1, the source code looks like this:
1. test hello
While on another domain, the source code looks like this:
1.
2.
3.
4.
5. test hello
This is exactly the same code, exactly the same file but called from a different domain name.
I have checked the encoding of wp-config.php and it is in UTF8 without BOM while other WP core files are in ASCII. I have tried to convert all other WP Core files in UTF8 without BOM but then I get the 4 lines on all my domains. If I convert wp-config back to ASCII, I still get 4 lines on some domains.
All domains are using the same database, the only difference is the theme used. They are all using different themes but I don't know how this would be related.
I also see the 4 empty lines in Wordpress admin on some domains but not on others.
I'm puzzled :(
Do you have any idea of what it going on? It doesn't prevent pages from being executed but it creates white space on top of every concerned sites (3 out of 15). I have tried reinstalled the current WP version but it didn't solve the issue.
Do you have any idea?
Thanks
Laurent

Wordpress can't edit some pages anymore

My Wordpress website has a strange problem: some pages cannot be updated anymore. It happens not with all pages, a few pages are working without problems.
After saving my edits, Wordpress shows me the message 'Your page is updated successfully' (or some other English translation) but it is not! My edit is gone and there is no extra revision.
What I tried so far:
Disabled all the plugins;
Disabled SSL;
Checked if server / plugin caching was enabled (it was not);
Disabled the browser cache;
Checked the .htaccess file (it's the default Wordpress .htaccess);
Rebuild the entire website (empty FTP and empty database);
Checked my (custom build) template for vulnerabilities;
Enabled the default twenty-seventeen theme;
Repaired the database (in DirectAdmin);
Contacted the webhoster (but they didn't understand the problem);
Moved the website to another domain;
Compared working pages with not working pages (but no difference);
Logged in with different users;
The error / debug log is empty and WP_DEBUG (and some PHP debug stuff) is enabled.
Suggestions are welcome ;)
Solution
I finally found the problem! Wordpress creates a GUID for each post. You can see the GUID in your database, or export your pages using the Wordpress export module.
For some strange reason, the content of the GUID is some text from the page itself. So, it looks like this:
strongWinterwerk%202016-2017/strongU/jij%20bent%20van%20harte%20welkom%20om%20één%20of%20meerdere%20activiteiten%20die%20in%20onze%20gemeente%20worden%20gehouden%20in%20de%20komende%20maanden%20te%20volgen.%20Hierbij%20ontvangt%20u%20de%20seizoenplanning%20en%20meer%20informatie%20over%20clubs%20en%20verenigingen%20
This GUID contains 317 characters. But, the database column can only store 255 characters. I changed it to 500 characters and my website works. Of course isn't this a good solution, but fine for now.
Just a few more questions:
Why is my GUID not just something like http://website.com/welcom-page?
If there is only room for 255 characters, why are there 317 stored while creating the post?

Wordpress site showing special charactors in site

My customer has a WordPress site and last week we have migrated it to a cPanel server after that the site showing special characters like ! and ? in the website. Can somebody let me know how to remove this?
Server: Centos 6
cPanel: WHM 56.0
PHP : 5.6.23
MySQL : 5.6
It's UTF8 Encoding problem, sometimes it happens when you migrate wordpress site from one host to another, you should select correct character set while exporting database backup.
Open and edit your WordPress wp-config.php file. Then find the following two lines and if it is not like that then you should change them as shown below.
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', ');
If this doesn't work try googling "special character problem wordpress"
PHP 5.6 changes the default value of default_charset to UTF-8. Change that value to ISO-8859-1 in your php.ini file and restart apache. See if that fix the issue.
Or convert the encoding of php textfiles to utf8 and don't change defaults.

Categories