0

I am building a web page in Romanian language and I want to appear on the web page the special Romanian characters (ș, ț, ă, î, â). I have introduced in the head of the html file the following code:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

but it does not work. Can somebody support me?

Adi S.
  • 53
  • 1
  • 10
  • Try instead of the one in your question. – Nekomajin42 Dec 26 '17 at 10:29
  • That only works if (a) You have actually encoded the HTML source code as UTF-8 and (b) The charset has not been overridden by a real HTTP header. – Quentin Dec 27 '17 at 22:24
  • @Quentin. (a)What do you mean by "encoded the HTML source code"? If inside the HTML I have used the special characters or if inside HTML I have used the codes ü for these special characters? In my HTML code I have used the special characters literally. (b) How do I know this? How can avoid this? Could you please post the link to the similar question to mine? Thanks. – Adi S. Dec 29 '17 at 19:21

2 Answers2

0

First set a header with PHP:

<?php header('Content-Type: text/html; charset=utf-8'); ?>

Note: call this function before any output has been sent to the client. See the manual page of header for more information.

php.net/manual/de/function.header.php

Then use the html5 version of header:

<head>
   <meta charset="UTF-8">
</head>

Last step save the file with the UTF-8 charset. This should work without replacing every special char with the masked version of it (&uuml; ...)

  • Thank you for the answer, but I'm quite lost. Regarding the header, should I create a separate php file with the code you mentioned or should I introduce this line of code in every php file I use for the web application? What should I save with the UTF-8 charset and how should I do this? – Adi S. Dec 26 '17 at 13:21
  • Instead using a .html file use .php (just change the filename). Then write the php code at the top, after that the HTML Like this: Depending which text Editor you use you have to check the charset setting (sometimes bottom right) – not-a-feature Dec 26 '17 at 19:19
  • I have done this, but now my site does not work. It could be because I have a mainpage with frames and when I write the file with the new .php extension in the mainpage frame, it shows me the .php file code in the frame instead of correctly displaying it. The charset setting is UTF-8. – Adi S. Dec 26 '17 at 19:46
  • You have to run the page on a webserver (like Apache) to use php. – not-a-feature Dec 26 '17 at 21:21
  • I am using wampserver for that. – Adi S. Dec 26 '17 at 21:50
-1

Try this code

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Page Title</title>
</head>
<body>

<h1>&#x219;</h1>
<h1>&#259;</h1>
<h1>&#539;</h1>
<h1>&#226;</h1>
<h1>&#238;</h1>
</body>
</html>

Output -- ș ă ț â î

Try this link https://websitebuilders.com/tools/html-codes/romanian/

Rahul K R
  • 191
  • 4
  • 20
  • Thanks for the answer. Maybe it was not very clear, but my need is not to output these Romanian characters by their own (separate). Instead, I want to have them visible inside the words from the web page. For example, if I want to show on the page the word "cărți", if I write this word exactly like this in the html file, I want to see it on the web page. Also, to not be necessary to replace each of these characters with the code. – Adi S. Dec 26 '17 at 13:28