Question: How to deal with non ASCII characters (German letters)

Started on the old forum in August 2011 · view the original in the archive · old links redirect here

10 replies · 1,193 views · started 15 years ago · 1 min read

TL;DR · summary of 10 replies
  • utf8 should work as well for German characters like ä, ö, ü, but switching Content-type charset might be necessary.
  • Changing both the database table character set and the page charset to UTF-8 could solve the issue with non-ASCII characters.
  • Using "Content-type: text/html; charset=latin1" alone did not work for some users, suggesting a combination of changes is needed.

Written automatically from the replies by a language model on our own server. It can be wrong; the posts below are the source.

6 participants
Mysterio Lead · 630 posts #1

I am working in a website containing German language, and there is many data to store in database (MySQL).

They gave me a database dump which I imported; but there are some German letters like "ä, ö, ü" stored in LONGTEXT fields and I am not being able to display them correctly. Any suggestion?

Thank you!

mysterio.al - programming is a functional art

pichiriche Junior · 38 posts #2

add after line sql connect this

mysql_query('SET NAMES 'utf8'');

and make tables in phpmyadmin character utf-8

something else Fellow · 2,296 posts #3

header("Content-type: text/html; charset=latin1");

ALTER TABLE table DEFAULT CHARACTER SET=latin1;

Mysterio Lead · 630 posts #4

Thank you guys! Will try both cases and tell you!

mysterio.al - programming is a functional art

something else Fellow · 2,296 posts #5

as far as im aware utf8 doesnt support ä, ö, ü etc

Mysterio Lead · 630 posts #7

It was not helping to change encoding of the table fields, until I switched to "Content-type: text/html; charset=latin1"

This seems to be a solution!

Thank you!

mysterio.al - programming is a functional art

CreativityKills Lead · 833 posts #8

Mysterio3 wrote: It was not helping to change encoding of the table fields, until I switched to "Content-type: text/html; charset=latin1"

This seems to be a solution!

Thank you!

when u change mysql charset also change page charset too.

Mysterio Lead · 630 posts #9

Yes, thanks!

I was getting confuse because UTF-8 or UTF-16 was not working, while latin1 did the job without touching database! That was my aim.

mysterio.al - programming is a functional art

metulj Super moderator Principal · 1,726 posts #10

Mysterio3 wrote: Yes, thanks!

I was getting confuse because UTF-8 or UTF-16 was not working, while latin1 did the job without touching database! That was my aim.

well... UTF-8 should work as well and it would be more appropriate for special chars like ä, ö, ü etc, also chars like č, ć, đ, š, ž, etc it just take a bit more time to figure it out 🙂

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close