Thread: [Cppcms-users] Apache utf8 headers
Brought to you by:
artyom-beilis
From: augustin <aug...@ov...> - 2012-07-02 06:07:07
|
Hello, I have 2 exactly identical web sites (same code, same html output), but one is set up to be started by the web server, and the other is set up to be started manually. See: http://cppcms.com/wikipp/en/page/cppcms_1x_tut_web_server_config#Apache In config.js, I have in both cases: "localization" : { "encoding" : "UTF-8", }, The html output contains in both cases: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> However, the apache headers are not the same. In the case of the manually started web site, the headers correctly specify: Content-Type text/html; charset=utf-8 while with the site started by the web server, the header specifies: Content-Type text/html; charset=us-ascii and thus I have to manually set my browser to display the web page in utf8 encoding to properly view the page. How come the apache Content-Type charset header is not the same? How to ensure the charset is the correct one? Also, where is the most appropriate place to rectify this? Should I set this in .htaccess? Should it be corrected from within the cppcms application, by declaring the proper http header? Should it be fixed in the apache settings for the web site (/etc/apache2/sites- available/mysite)? Maybe I should use this: http://cppcms.com/cppcms_ref/latest/classcppcms_1_1http_1_1response.html but I am confused by the discrepancy between the two sites, given that they have the same code and the same settings. Can this be considered as a small bug in cppcms? Thanks, Augustin. -- Friends: http://www.reuniting.info/ My projects: http://astralcity.org/ http://lesenjeux.fr/ http://linux.overshoot.tv/ http://overshoot.tv/ http://charityware.info/ http://masquilier.org/ http://openteacher.info/ http://minguo.info/ http://jacqueslemaire.fr/ http://www.wechange.org/ http://searching911.info/ . |
From: augustin <aug...@ov...> - 2012-07-02 06:15:37
|
On Monday, July 02, 2012 02:06:45 PM augustin wrote: > Maybe I should use this: > http://cppcms.com/cppcms_ref/latest/classcppcms_1_1http_1_1response.html > but I am confused by the discrepancy between the two sites, given that > they have the same code and the same settings. > Can this be considered as a small bug in cppcms? I fixed this by adding the following in my application: response().content_type("text/html; charset=UTF-8"); but maybe this is not the most appropriate way to handle this, or cppcms could have guessed the proper encoding from config.js. And if this is the proper solution, hopefully by putting it here, it will help someone else. Augustin. -- Friends: http://www.reuniting.info/ My projects: http://astralcity.org/ http://lesenjeux.fr/ http://linux.overshoot.tv/ http://overshoot.tv/ http://charityware.info/ http://masquilier.org/ http://openteacher.info/ http://minguo.info/ http://jacqueslemaire.fr/ http://www.wechange.org/ http://searching911.info/ . |
From: Artyom B. <art...@ya...> - 2012-07-02 06:30:50
|
The encoding option is not in use for a LOOOONG time http://cppcms.com/wikipp/en/page/cppcms_1x_config#localization CppCMS automatically sets the Content-Type charset according to the process locale, if apache starts the web server using C locale than by default you'll get us-ascii charset. The correct solution is to define the locale for the cppcms service "localization" { "locales" : [ "en_US.UTF-8" ] } Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ >________________________________ > From: augustin <aug...@ov...> >To: cpp...@li... >Sent: Monday, July 2, 2012 9:15 AM >Subject: Re: [Cppcms-users] Apache utf8 headers > >On Monday, July 02, 2012 02:06:45 PM augustin wrote: >> Maybe I should use this: >> http://cppcms.com/cppcms_ref/latest/classcppcms_1_1http_1_1response.html >> but I am confused by the discrepancy between the two sites, given that >> they have the same code and the same settings. >> Can this be considered as a small bug in cppcms? > >I fixed this by adding the following in my application: > response().content_type("text/html; charset=UTF-8"); >but maybe this is not the most appropriate way to handle this, or cppcms could >have guessed the proper encoding from config.js. > >And if this is the proper solution, hopefully by putting it here, it will help >someone else. > > > >Augustin. > > > >-- >Friends: http://www.reuniting.info/ >My projects: >http://astralcity.org/ http://lesenjeux.fr/ http://linux.overshoot.tv/ >http://overshoot.tv/ http://charityware.info/ http://masquilier.org/ >http://openteacher.info/ http://minguo.info/ http://jacqueslemaire.fr/ >http://www.wechange.org/ http://searching911.info/ > > > > > > > > > > > > >. > >------------------------------------------------------------------------------ >Live Security Virtual Conference >Exclusive live event will cover all the ways today's security and >threat landscape has changed and how IT managers can respond. Discussions >will include endpoint security, mobile security and the latest in malware >threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >_______________________________________________ >Cppcms-users mailing list >Cpp...@li... >https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > |
From: augustin <aug...@ov...> - 2012-07-02 06:51:13
|
On Monday, July 02, 2012 02:30:38 PM Artyom Beilis wrote: > The encoding option is not in use for a LOOOONG time :) Sorry! > > http://cppcms.com/wikipp/en/page/cppcms_1x_config#localization > > The correct solution is to define the locale for the cppcms service > > "localization" { > "locales" : [ "en_US.UTF-8" ] > } Thanks. I'll try that. Do you think it's worthwhile creating a wiki page to collate all utf8/encoding FAQs? There was already a question on this list about cppdb and utf8. I can create one if you wish. Augustin. -- Friends: http://www.reuniting.info/ My projects: http://astralcity.org/ http://lesenjeux.fr/ http://linux.overshoot.tv/ http://overshoot.tv/ http://charityware.info/ http://masquilier.org/ http://openteacher.info/ http://minguo.info/ http://jacqueslemaire.fr/ http://www.wechange.org/ http://searching911.info/ . |
From: Artyom B. <art...@ya...> - 2012-07-02 07:36:03
|
>Do you think it's worthwhile creating a wiki page to collate all utf8/encoding >FAQs? There was already a question on this list about cppdb and utf8. >I can create one if you wish. > >Augustin. > Not bad idea at all Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ |
From: augustin <aug...@ov...> - 2012-07-03 07:36:41
|
On Monday, July 02, 2012 03:35:52 PM Artyom Beilis wrote: > >Do you think it's worthwhile creating a wiki page to collate all > >utf8/encoding FAQs? There was already a question on this list about > >cppdb and utf8. I can create one if you wish. > > > >Augustin. > > Not bad idea at all Here you are: http://cppcms.com/wikipp/en/page/cppcms_1x_encoding_and_utf8 The article can be completed as new problems and questions arise. Yours, Augustin. -- Friends: http://www.reuniting.info/ My projects: http://astralcity.org/ http://lesenjeux.fr/ http://linux.overshoot.tv/ http://overshoot.tv/ http://charityware.info/ http://masquilier.org/ http://openteacher.info/ http://minguo.info/ http://jacqueslemaire.fr/ http://www.wechange.org/ http://searching911.info/ . |