How to get my site using UTF-8 (PHP site) - utf-8

First time poster and hoping to solve a very frustrating issue.
In Google chrome, my PHP site displays random characters such as Â. However, when I switch the encoding to UTF-8 all the random characters clear up.
I've been reading elsewhere that that I need to tell me site to use UTF-8 by default. My host say this is already enabled on their side.
What code do I add and where to solve this issue?

Put:
<meta http-equiv='content-type' content='text/html; charset=utf-8'/>
In the <head> of the document, and it should force the page to render utf-8 characters properly.
Further description: In your HTML page, you would have the page layed out as such:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<meta http-equiv='content-type' content='text/html; charset=utf-8'/>
<!--<link> tags for any CSS-->
<!--<script> tags for any JS-->
<!--Anything else in the head-->
</head>
<body>
<!--Page contents-->
</body>
</html>

Related

Mailchimp Post Lists returns HTML document?

I am starting my first mailchimp integration
I'm not posting any code as it is in a vertical market language called Dataflex so I don't think it would help explain my question...
I have successfully made GET requests to return the information about all lists
However when I try to POST to the lists endpoint to create a new list ...
The call seems to be received OK
The new list is NOT created
The mailchimp response is not in JSON format but what looks like a complete HTML page starting ...
<!DOCTYPE html>
<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8"><![endif]-->
<!--[if IE 8]><html class="no-js lt-ie9"><![endif]-->
<!--[if gt IE 8]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
<meta name="generator" content="Hugo 0.50" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Developer | Mailchimp</title>
Has anyone experienced this kind of strange response when it should be returning JSON ?
Thanks in advance

Jsreport rendering russian language

When I render jsreport pdf using phantom and html-to-pdf with character from russian, they become weird symbols. Is there any settings in jsreport or I need correct font in the server machine?
http://jsreport.net/learn/phantom-pdf
Phantom-pdf is currently not able to print some national characters by
default. To be able to print correct national characters into pdf you
need to set utf-8 charset in your html first.
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body>
Česko
</body>
</html>

a href not working with a bare web page

I've been looking around for a solution to the problem I'm having, but it seems that none of the solutions on SO address my issue.
I was having the dreaded issue where the a href tag in my HTML does not actually take me to the link. At first, I tried removing the JavaScript includes, wondering if something in the JavaScript portion was messing up the page.
Then I removed the CSS portion as well, and ultimately removed everything until the page consisted of simply the header information for the HTML page and only the a href tag. I also changed the link to a non-existent page (to force a 404 error).
When clicking on the link, it keeps me on the current page and doesn't take me to the referenced page (or even give me a 404 error). Following is the stripped out code (everything but the commented out portion):
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>test</title>
<meta name="description" content="test1" />
<meta name="keywords" content="test2" />
</head>
<a href="test.html">Support</a/>
</html>
Thanks for the help.
I made the changes based on the answers given but still see the same behavior. As seen in the screenshot (sorry SO doesn't let me insert images), the URL shows /test.html but the page is still the main page. I changed the text of the link to ensure that the changes were applied.
I'm using rackup to quickly view the changes locally.
Screenshot
Updated code:
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>test</title>
<meta name="description" content="test1" />
<meta name="keywords" content="test2" />
</head>
<body>
Support2
</body>
</html>
Working and tested:
NOTE: Both files [ current one and test.html ] are in same directory.
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>test</title>
<meta name="description" content="test1" />
<meta name="keywords" content="test2" />
</head>
<body>
Support
</body>
</html>
Also test code is working fine using target="_blank" in anchor tag , which open link in new page if working fine, like below:
<a href="test.html" target="_blank" > support </a>
You have an extra slash in your closing a tag.
Should be
</a>.
I would also make sure they are in the same directory.
Apparently the answer was here:
How to setup URLs for static site with Ruby Rack on Heroku
Individual pages were being routed to "/" all the time. Needed to modify "config.ru" to get routing to work properly.
Next step is to look into "sinatra".

Using Rails partial breaks document tree?

For some reason when I use a partial for the content in my Rails app, my HTML document tree breaks and the head elements spill over the body element. I've boiled this down to a very simple example:
app/views/layouts/application.html.erb:
<!doctype html>
<html>
<head>
<%= render :partial => 'shared/head' %>
</head>
<body id="test-id">
<h1>Hello World</h1>
</body>
</html>
app/views/shared/head.html.erb:
<title>Test Title</title>
result
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<title>Test Title</title>
<h1>Hello World</h1>
</body>
</html>
Note that the id attribute on was lost and the element is not where it should be.
Has anybody seen anything like this or can provide tips for debugging?
I'm running:
OSX 10.8.3
ruby-1.9.3-p392
rails 3.2.11 / WEBrick
Spree 1.1.4 (although I've stripped out anything that Spree might affect)
Turns out I had Deface running in the background which was causing an error which was mangling my <head>.
If anybody is running Spree and sees weird issues with their templating, first look at the Rails logs for Deface errors and check your libxml version. If it's > 2.8.0 you may need to downgrade. More info here.

Issues forcing IE9 to render like IE8

I'm trying to render a webpage in Explorer as IE8, since IE9 is doing a great mess with CSS and not showing the #font-face.
I read the Microsoft Documentation here: http://msdn.microsoft.com/en-us/library/cc288325%28v=vs.85%29.aspx and other related topics like IE9 does not at all care about 'X-UA-Compatible' meta tag and Force IE9 to emulate IE8. Possible? and none resolved my issue, either I am very dumb (witch can be) or I can't find the problem.
The webpage is: karactermania.com/web2012/betty and I'm using the CMS Textpattern to build it.
I tried with:
<!-- Enable IE8 Standards mode -->
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<!-- Enable IE8 Standards mode -->
<meta http-equiv="X-UA-Compatible" content="IE8" /> (as I found some examples written with and without the "=")
<!--[if IE 9]>
<meta http-equiv="X-UA-Compatible" content="IE8" >
<![endif]--> (desperate attempt)
Complete HTML declaration:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="es" xmlns:fb="http://ogp.me/ns/fb#">
<head>
<!-- Enable IE9 Standards mode -->
<meta http-equiv="X-UA-Compatible" content="IE8" />
If anyone can point where the error is and how can I fix it, will earn my eternal gratitude :)
Thanks
I had the same problem as you. My X-UA-Compatible header was ignored. I found the solution in this post
The x-ua-compatible header has to be in the head section, before all other elements except for the title element and other meta elements

Resources