How can I set UTF-8 in Symfony? - symfony

I don't know what else to try; each time I render a twig template, I get those symbols:
�
Instead of "á" for example.
Each template, extends a "base" template, which cointains:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
But that symbol is still shown. I checked sourcecode of the page rendered, and that meta tag line appears there.
Is there any global configuration I've to set to avoid this?
Thank you!
Edit: Note that I'm using TWIG. Maybe some Twig parameters are missconfigured?

You should use à, see the html special characters
To do this dynamically: look at the php function htmlspecialchars()

Related

<textarea> output is not well encoded

This is my first question, so sorry if I make any mistake in my explanations.
I created a website based on Wordpress that uses a Newsletter plugin.
I'm not using that plugin, I'm using it only to generate an HTML newsletter.
Here is how it goes : I got to a specific page in my back-office and there is dropdown selection where I can pick up articles from specific categories in my blog.
Once I selected what I want, I have my "Generate" button that :
Generate HTML code based on a php template I created
Show me a preview
To prevent any encoding error, I used the str_replace function with a lot of characters.
That works very well for my preview, but not for the generated code (that appears in a textarea).
So I was wondering how to fix this, because in the textarea I have "�" and some "Â" appearing in my content.
For your information, this is the only problem I have, on the website everything shows well, it's just on that Newsletter Generator that I have an issue !
Thanks for your help !
Have you tried placing the following in your header template? Within head, before the <title tag.
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
Thanks for your help and answers,
I finally solved it that way :
In the PHP file that output the generated HTML code (in the textarea), the outpu was generated that way :
htmlentities($newsletter);
And I replaced it by this :
htmlentities($newsletter, ENT_QUOTES | ENT_IGNORE, "UTF-8");
And now it seems to work like a charm !! I will come back if there is any more issue, but that way works for me and the generated HTML code is now well and don't show any weird character !
Thanks to all of you :)

Include og: tags in Meteor App

I have read How to integrate Facebook's Open Graph in a Meteor application? and followed it closely, however, the og tags are still not registered):
I would just like to set several images to ensure that several thumbnails appear when u type http://bubble.meteor.com in facebook
Here are my codes:
(Updated)
<head>
...
<meta property="og:image" content="http://bubble.meteor.com/img/ogimage1.png">
<meta property="og:url" content="http://bubble.meteor.com">
<meta property="og:title" content="Emory Bubble">
</head>
Am I doing anything wrongly? Thanks!
First of all, an <html> tag does not belong inside the <head>. Meteor always uses the HTML5 doctype definition. Even if you would manage to change it to XHTML, you will probably end up with invalid XHTML, because extension packages that inject HTML assume HTML5.
Second, there is no need to declare any namespace for the OpenGraph tags. Strings like "og:title" are just opaque data inside a property and they do not affect the HTML parser.
UPDATE
I checked it using Facebook's debug page and it does not work indeed:
http://developers.facebook.com/tools/debug
This yielded an "Error parsing input URL, no data was scraped" error.
I also checked the page using the special escaped fragment URL that should trigger the spiderable package:
http://bubble.meteor.com/?_escaped_fragment_=
The resulting page contains no HTML content and the Javascript tags were still present, suggesting that the spiderable package does not work. Did you add that one to your project? (meteor add spiderable).
If you added it, it does not work. The spiderable package returns the normal page if running PhantomJS fails. You should check it on your local development version, use the above URL to trigger spiderable.
I also noticed that you are using 'school' as og:type, which is not a valid type as far as I know. Try 'website' instead.
UPDATE 2
Also checkout this screencast by Chris Mather about the spiderable package:
http://www.eventedmind.com/posts/meteor-the-spiderable-package
In this screencast he mentions a potential problem with subscriptions that are never marked as ready and make the spiderable package fail. Maybe this is causing your issues?

Meta tag not in first 1024 bytes

Caveat: Before someone goes and marks this as duplicate of this, please understand that it is not. The accepted answer is exactly what I am doing, yet I am facing the following issue.
HTML file in client folder looks like this:
<head>
<meta charset="utf-8"/>
<title>blah-blah</title>
---
The message I am getting in the firebug console is:
The character encoding declaration of the HTML document
was not found when prescanning the first 1024 bytes of
the file. When viewed in a differently-configured browser,
this page will reload automatically. The encoding
declaration needs to be moved to be within the first
1024 bytes of the file.
When I do a view source, between the head and the meta charset element, I see a whole bunch of link stylesheet and script tags.
If I remove the meta charset, I get this in the firebug console:
The character encoding of the HTML document was not
declared. The document will render with garbled text
in some browser configurations if the document
contains characters from outside the US-ASCII range.
The character encoding of the page must to be declared
in the document or in the transfer protocol.
How do I get the meta charset tag to appear right after the head?
What I did was edit /usr/lib/meteor/app/lib/app.html.in, and add the meta charset line so that the file now looks like this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/> //**Added this line**
{{#each stylesheets}} <link rel="stylesheet" href="{{this}}">
{{/each}}
...
And of course I removed the meta charset line from my html files.
I think right now, this would be the way to go and this will be resolved in future revisions.
I had the problem in IE to force to use the latest version.
I had to add
<meta http-equiv="x-ua-compatible" content="IE=edge">
Directly behind the tag. And app.html.in seems not to be used anymore.
So I did this on tools/latest/tools/bundler.js
Line 783
'<head><meta http-equiv="x-ua-compatible" content="IE=edge">\n');
That forced it to add it in the html boilerplate.

problem with hebrew in wordpress

i want to change the SearchForm.php file in my wordpress themes to hebrew.
i mean i want to see 'חפש' (hebrew text) instead of 'search for '.
when i change it i see gebrish.
why ??
thanks.
You need to make sure that the content-type of the page is the correct one - normally UTF-8 would work for all languages.
You can use a meta tag within the head element:
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
For Hebrew it is iso-8859-8.
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-8">
This is normally already setup within the template and you can look at your settings to see if it is correct - In Settings -> Reading, under "Encoding for pages and feeds".
You also need to be sure that the page is saved as UTF-8 and not ascii - check your text editor settings.

Duplicate <meta> in Drupal variable $head

I am trying to customize the $head variable in my page.tpl.php template, because there are two instances of
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
appearing, which I believe is affecting the site from being validated using W3C's Markup Validation Service. Any help would be much appreciated, thanks!
Well, first of all I'd try and figure out WHY you're getting duplicates of that. Manually removing one is more of a hack than a fix.
That said, you can customize $head using template_preprocess_page. In your theme's template.php, do something like:
<?php
function THEMENAME_preprocess_page(&$variables) {
// use $variables['head'] here and do whatever you want with it, such as...
$variables['head'] = str_replace('blah blah','blah',$variables['head']);
// ...although that's completely untested and might not work
}
This seems to be a bug in the Drupal API, the discussion can be followed here:
http://drupal.org/node/451304#comment-2632954
Seems that even drupal.org is duplicating the content type meta tag.

Resources