Open CaroeK opened 6 years ago
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.
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.
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.
I can change the PHP.ini.
1) That might work, not 100% certain. I have done it through IIS and Azure app settings myself.
2) Yes
Damn....just tried.... wasn't enough.... no change :(
Looks like it needs to be set at the Apache INI level or maybe .htaccess
https://stackoverflow.com/questions/10902433/setting-environment-variables-for-accessing-in-php
http://www.smorgasbork.com/2017/10/20/apache-php-environment-variables/
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:
Then I reinstalled WordPress and now it works. Thanks.
@CaroeK (and @patrickebates ): I'm guessing that this issue has been fully resolved via #422 . Unless it was an entirely different issue. Reading through the comments it appears that this issue deals mostly with configuration (i.e. proper setting of ProjectName.UTF8
), However, it might not have been possible to confirm the fix recommend above without #422 in place (even if the example "special" characters shown in the initial post worked as of the last comment on 2018-08-31, that doesn't mean that other "special" characters, such as "𒂭" work). @CaroeK , can you please confirm that this is fully resolved and close it out, or confirm that characters such as "𒂭" do not work, in which case this can probably still be closed referencing #422 which ultimately will fix that remaining issue (which I suspect is the case as I don't see how "𒂭" could save correctly without the update provide in #422).
Thanks and take care, Solomon..
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 :)