How do I enter anad render Germany Characters: > ö <

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

How do I enter anad render Germany Characters: > ö <

Post by simonmlewis »

I need to render Germany characters on screen.
I have read a few pages on it, but they seem to tell you to add a ton of code. But if you search for "germany Zubehör" on Google, results come up with that characters correctly shown, using UTF-8 I'm sure.

So how do you do it?
Mine are coming up as the diamonds.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: How do I enter anad render Germany Characters: > ö <

Post by requinix »

Pick a character encoding. For example, UTF-8. Then make sure:
1. Your web pages are using UTF-8, like with a <meta charset>.
2. Your PHP files are saved using UTF-8, in case you put non-ASCII characters in them.
3. Your database connection is using UTF-8.
4. Your databases, tables, and columns are all using UTF-8.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do I enter anad render Germany Characters: > ö <

Post by simonmlewis »

1. Your web pages are using UTF-8, like with a <meta charset>.
Yes that is done

2. Your PHP files are saved using UTF-8, in case you put non-ASCII characters in them.
I use Notepad to do that. But not sure how to ensure it is UTF-8??

3. Your database connection is using UTF-8.
How do I check that?

4. Your databases, tables, and columns are all using UTF-8.
How do I check this please?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do I enter anad render Germany Characters: > ö <

Post by simonmlewis »

I've checked the notepad2 screen and it says ANSI, which I am assured is correct.
The database connect script was made using that.
The tables are now: utf8_german2_ci. Is that correct?
The text from the DB are still showing diamonds.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: How do I enter anad render Germany Characters: > ö <

Post by requinix »

simonmlewis wrote:2. Your PHP files are saved using UTF-8, in case you put non-ASCII characters in them.
I use Notepad to do that. But not sure how to ensure it is UTF-8??
Why are you using Notepad to write code? WHYYY!?
simonmlewis wrote:3. Your database connection is using UTF-8.
How do I check that?
simonmlewis wrote:4. Your databases, tables, and columns are all using UTF-8.
How do I check this please?
Have a read through this. Yes, there is a lot to read.
simonmlewis wrote:I've checked the notepad2 screen and it says ANSI, which I am assured is correct.
So, wait, you're using Notepad2? Not Notepad?

You are assured? Meaning someone told you that is correct? Because they're wrong.
Perhaps you mean "assumed", as in "I saw the term 'ANSI' and, rather than Google it to see what it means, I assumed it's the same thing as UTF-8".

However, as long as you aren't putting anything beyond simple ASCII characters into your files, you will be fine with that.
simonmlewis wrote:The database connect script was made using that.
The tables are now: utf8_german2_ci. Is that correct?
The text from the DB are still showing diamonds.
That is UTF-8 using a German language collation. (That link from earlier explains what collations are too.)
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do I enter anad render Germany Characters: > ö <

Post by simonmlewis »

I read something on a page about Notepad2 that tells me ANSI is correct for UTF-8.
Therefore, I am "assured".

I have used Notepad and then Notepad2 for goodness knows how many years.

Sorry I am at a loss.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do I enter anad render Germany Characters: > ö <

Post by simonmlewis »

I have a bit of an update on this.

Code: Select all

<!DOCTYPE html>
<html lang="de-de">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
ausgefüllt
</body>
</html>
This echoes it wiht the black diamond.
If I simple save "ausgefüllt", it renders fine.

So something in that code is causing it.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: How do I enter anad render Germany Characters: > ö <

Post by requinix »

If that file is showing question marks then you did not save it using UTF-8 encoding.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do I enter anad render Germany Characters: > ö <

Post by simonmlewis »

If I do it with straightforward Windows Notepad, I have the same issue.
What's the usual tool people use? I have used Notepad2 for more years than I can remember.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do I enter anad render Germany Characters: > ö <

Post by simonmlewis »

Well I'll be damned. I found it in Notepad2 where you change the encoding! Brilliant.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do I enter anad render Germany Characters: > ö <

Post by simonmlewis »

The only issue now is that words that were perhaps not "INSERTED" with UTF-8, are rendering still with the black triangles.
Is there some tool I can run to convert them all? So all titles, category names etc are output as utf-8?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How do I enter anad render Germany Characters: > ö <

Post by Celauran »

simonmlewis wrote:What's the usual tool people use? I have used Notepad2 for more years than I can remember.
Most people I know in the field use either Sublime Text or Atom. That's not related to your problem, but since you ask. Both certainly seem more capable than Notepad2
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do I enter anad render Germany Characters: > ö <

Post by simonmlewis »

I'll look into them.
I've just backed up the database tables.
Deleted the database.
Recreated it as UTF8.
Imported the tables.
And still for the rendered content that has those characters, they show as black diamonds.

The database connection file is utf-8 saved.
So is the template file.
So is the internal file I am testing it with.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: How do I enter anad render Germany Characters: > ö <

Post by requinix »

simonmlewis wrote:I've just backed up the database tables.
Deleted the database.
Recreated it as UTF8.
Imported the tables.
And still for the rendered content that has those characters, they show as black diamonds.
The database's encoding sets the default encoding for new tables.
The table's encoding sets the default encoding for new columns.
The column's encoding is what actually matters as the column is what contains the data.

So if you really just recreated the database itself and simply imported the backed up tables then you won't have actually changed anything. Change the default encoding on all the tables, then change the encoding on each text (CHAR, VARCHAR, TEXT, etc.) column you have.


Remember that link I posted a while back? And told you to read through, even though there was a lot to read through? Did you read just that one page or did you look through all the documentation on character encodings and collations?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do I enter anad render Germany Characters: > ö <

Post by simonmlewis »

Umrüstsätze

Honestly? Not read through a lot of it. I do need to understand it, but I also need to fix the issue fairly quickly too.

The Collation of each field is: utf8_general_ci
But for example, I have updated a title, and the database is storing it like this: Umrüstsätze

So on the current version of the site, the links are broken because of the way it's rendered in the previous html code.
Surely it should store them with the correct wording? Is it not possible to just update all fields to be utf8 as well as "new" entries??
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply