New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special characters not showing correct #303

Open
CaroeK opened this Issue Aug 31, 2018 · 10 comments

Comments

Projects
None yet
2 participants
@CaroeK
Copy link

CaroeK commented Aug 31, 2018

Hi again.
I'm using local installed SQL Express. In my cumstom PHP pages the special characters (æ ø å) are shown as som weird signs. I have tried a lot of different stuff in PHP and in HTMl, but nothing changes this. Selecting them in Management studio shown the correct characters. If found som old posts here about it, but I don't know where the problem is. Is it in MSSQL (I use the collation Danish_Norwegian_CI_AS and nvarchar), or in my custom PHP or the projectnami wordpress installation?
In wordpress I have select the Danish language and when I create a normal page in wordpress it can show the special characters. It only in my custom PHP it doesn't work.
Can you provide me with som help please :)

@CaroeK

This comment has been minimized.

Copy link
Author

CaroeK commented Aug 31, 2018

I tried to change the following

if ( getenv('ProjectNami.UTF8') ) {
$this->dbh = sqlsrv_connect( $this->dbhost, array( "Database"=> $this->dbname, "UID"=> $this->dbuser, "PWD"=> $this->dbpassword, 'ReturnDatesAsStrings'=>true, 'MultipleActiveResultSets'=> false, 'CharacterSet'=> 'UTF-8') );
} else {
$this->dbh = sqlsrv_connect( $this->dbhost, array( "Database"=> $this->dbname, "UID"=> $this->dbuser, "PWD"=> $this->dbpassword, 'ReturnDatesAsStrings'=>true, 'MultipleActiveResultSets'=> false, 'CharacterSet'=> 'UTF-8') );
}
in wp-db.php

Then my custom PHP works and shows the correct characters, but the WordPress it self shows the wrong characters now. Maybe it helps you helping me. I don't get it.

@patrickebates

This comment has been minimized.

Copy link
Member

patrickebates commented Aug 31, 2018

So two possibilities. First, if your own tables are using datatypes of char or varchar rather than nchar or nvarchar, that could be contributing to the issue you are seeing.

Second, regarding the forcing of UTF-8 charset. It has to be enabled before beginning the install or the posts and pages added before setting it become unusable. It might even cause some issues with site options and similar settings.

@CaroeK

This comment has been minimized.

Copy link
Author

CaroeK commented Aug 31, 2018

  1. I found the issues about varchar and nvarchar, so i dropped and recreated the table with nvarchar. Then I filled in the data again. So that should not be the problem.
  2. Okay, so I have to do the installation from scratch. No problem, but I don't know exactly where I have to change the setting? I use xampp with apache on Windows 10. Can you provide me with at precise place to enable it? Thanks very much for your help.
@patrickebates

This comment has been minimized.

Copy link
Member

patrickebates commented Aug 31, 2018

I'm not fully versed with Apache, but do you have a location where you can set custom environment variables for PHP? Maybe a user.ini or just go in and add something to the php.ini directly?

In the code you posted above

if ( getenv('ProjectNami.UTF8') ) {

So if you set ProjectNami.UTF8 = 1 somewhere, that will force UTF-8 connections from now on and persist through code updates.

@CaroeK

This comment has been minimized.

Copy link
Author

CaroeK commented Aug 31, 2018

I can change the PHP.ini.

  1. Can I just put
    ProjectNami.UTF8 = 1;
    Somewhere in the php.ini ?
  2. I still have to reinstall the WordPress site right?
@patrickebates

This comment has been minimized.

Copy link
Member

patrickebates commented Aug 31, 2018

  1. That might work, not 100% certain. I have done it through IIS and Azure app settings myself.

  2. Yes

@CaroeK

This comment has been minimized.

Copy link
Author

CaroeK commented Aug 31, 2018

Damn....just tried.... wasn't enough.... no change :(

@patrickebates

This comment has been minimized.

@patrickebates

This comment has been minimized.

@CaroeK

This comment has been minimized.

Copy link
Author

CaroeK commented Aug 31, 2018

Thank you for super fast and very helpfull help 🥇
I modified the C:\xampp\apache\conf\extra\httpd-xampp.conf file and added the last line in this section:

SetEnv MIBDIRS "C:/xampp/php/extras/mibs"
SetEnv MYSQL_HOME "\xampp\mysql\bin"
SetEnv OPENSSL_CONF "C:/xampp/apache/bin/openssl.cnf"
SetEnv PHP_PEAR_SYSCONF_DIR "\xampp\php"
SetEnv PHPRC "\xampp\php"
SetEnv TMP "\xampp\tmp"
SetEnv ProjectNami.UTF8 "1"

Then I reinstalled WordPress and now it works. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment