Why Do Symbols Like Apostrophes and Hyphens Get Replaced with Black Diamonds on My Website

Why do symbols like apostrophes and hyphens get replaced with black diamonds on my website?

It's an encoding problem. You have to set the correct encoding in the HTML head via meta tag:

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

Replace "ISO-8859-1" with whatever your encoding is (e.g. 'UTF-8'). You must find out what encoding your HTML files are. If you're on an Unix system, just type file file.html and it should show you the encoding. If this is not possible, you should be able to find out somewhere what encoding your editor produces.

Diamond with Questionmark in fonts

If someone else have this problem, I guess this could help:

The issue was, the theme creators used substr function to remove the extra characters from the excerpt. So this function was removing the characters which are obsolete when stand alone in this language and the browsers are not finding a way to represent these. So it comes up with the question marks in the diamonds. So I removed the substr function and limited the excerpt with lesser number of words to achieve the same functionality without breaking the layout of the theme.

And it worked!

Question mark characters display within text. Why is this?

The following articles will be useful:

10.3 Specifying Character Sets and Collations

10.4 Connection Character Sets and Collations

After you connect to the database, issue the following command:

SET NAMES 'utf8';

Ensure that your web page also uses the UTF-8 encoding:

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

PHP also offers several functions that will be useful for conversions:

  • iconv
  • mb_convert_encoding

Java / HTML encoding issues (dash becomes –)

You should try setting the encoding in the constructor of your string:

subject = new String(subject.getBytes("UTF-8"), "UTF-8");

Question mark with diamond when read nvarchar from SQL Server

Refer to this question

Like @Arvind said, it runs correctly in IDE/Editor, because it's already encoded as UTF-8.

However, the jar or tomcat isn't, so we have to make sure it runs with encoding UTF-8.

  1. In Windows 10 CMD, the jar file could run like this:

> java -Dfile.encoding="UTF-8" -jar test.jar

However this command couldn't run in PowerShell, I don't know why it's another issue.


  1. If you want to run war file on tomcat server, in {pathToTomcat}/bin, open catalina.bat with editor.

add set "JAVA_OPTS=%JAVA_OPTS% -Djavax.servlet.request.encoding=UTF-8 -Dfile.encoding=UTF-8"

Why do quotes turn into funny characters when submitted in an HTML form?

This looks like a classic case of unicode (UTF-8 most likely) characters being interpreted as iso-8859-1. There are a couple places along the way where the characters can get corrupted. First, the client's browser has to send the data. It might corrupt the data if it can't convert the characters properly to the page's character encoding. Then the server reads the data and decodes the bytes into characters. If the client and server disagree about the encoding used then the characters will be corrupted. Then the data is stored in the database; again there is potential for corruption. Finally, when the data is written on the page (for display to the browser) the browser may misinterpret the bytes if the page doesn't adequately indicate it's encoding.

You need to ensure that you are using UTF-8 throughout. The default for web pages is iso-8859-1, so your web pages should be served with the Content-Type header or the meta tag

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

(make sure you really are serving the text in that encoding).

By using UTF-8 along all parts of the process you will avoid problems with all working web browsers and databases.

data from database is not inserted into my webpage properly

The following articles will be useful

http://dev.mysql.com/doc/refman/5.0/en/charset-syntax.html

http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html

After you connect to the database issue the following command:

SET NAMES 'utf8';

Ensure that your web page also uses the UTF-8 encoding:

PHP also offers several function that will be useful for conversions:

http://us3.php.net/manual/en/function.iconv.php

http://us.php.net/mb_convert_encoding

Unresolved external symbol. C++

I added add_definitions(-DQT_DLL) to my CMakeLists.txt and now it's compiled.



Related Topics



Leave a reply



Submit