Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Encodingsettings for html_select_date
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
regsnerven
Smarty Rookie


Joined: 26 Mar 2010
Posts: 20

PostPosted: Mon May 03, 2010 3:15 pm    Post subject: Encodingsettings for html_select_date Reply with quote

Hey guys,

my site is running in UTF8. The Problem now is that your html_select_date plugin is working with ISO-8859-1 so i got this "M�rz" instead of "März" which is March in english.

How cand i fix it?
I am using version 1.3.4 of the plugin by the way.

Gr33tZ
Rn

Edit:

Okay, some things i should also mention:
Windows-Apache-Server,
setlocale(LC_ALL, 'de_DE@euro.UTF8', 'de_DE.UTF8', 'deu_deu.UTF8', 'de.UTF8', 'ge.UTF8', 'de_DE@euro', 'de_DE', 'deu_deu', 'de', 'ge');

Basically it is right, but because windows does not support UTF8 it just can work.

Doesn't matter. That need to be fixed Wink
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7366
Location: Lincoln Nebraska, USA

PostPosted: Tue May 04, 2010 2:00 am    Post subject: Reply with quote

How is the html_select_date plugin tied to ISO-8859-1? It should work with utf8 no problem. Just be sure things are setup in PHP correctly (locale) and your html charset matches.
Back to top
View user's profile Send private message Visit poster's website
regsnerven
Smarty Rookie


Joined: 26 Mar 2010
Posts: 20

PostPosted: Wed May 05, 2010 9:10 am    Post subject: Reply with quote

i am sure. Everthing else is working.

But i think, like i already mentionend, that it is a problem with windows because there is no locale value with '.UTF8'.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7366
Location: Lincoln Nebraska, USA

PostPosted: Wed May 05, 2010 1:47 pm    Post subject: Reply with quote

html_select_date uses strftime() and htmlspecialchars() internally to format a date. Once you have that working, then html_select_date should too.
Back to top
View user's profile Send private message Visit poster's website
regsnerven
Smarty Rookie


Joined: 26 Mar 2010
Posts: 20

PostPosted: Thu May 06, 2010 10:53 am    Post subject: Reply with quote

Ehm..i cant find "htmlspecialchars()" in function.html_select_date.php and the only html escape function with charset-support i can find is in modifier.escape.php. But i dont know that can help me.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7366
Location: Lincoln Nebraska, USA

PostPosted: Thu May 06, 2010 1:14 pm    Post subject: Reply with quote

see the shared file that html_select_date function uses for escapement.
Back to top
View user's profile Send private message Visit poster's website
regsnerven
Smarty Rookie


Joined: 26 Mar 2010
Posts: 20

PostPosted: Thu May 06, 2010 1:53 pm    Post subject: Reply with quote

yeah,
it's shared.escape_special_chars.php but there is nothing with encoding settings.

Why there is not property of smarty which is defining the global to use charset?
$smarty->charset = 'UTF8' or something. Would be much easier than this.

What should i do in this shared file to keep it dynamic and make it work for my needs?
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7366
Location: Lincoln Nebraska, USA

PostPosted: Thu May 06, 2010 3:12 pm    Post subject: Reply with quote

That is what I'm saying, there isn't anything in Smarty that is character set specific. So long as you have PHP setup correctly, and your HTML page character set is correct in the browser, your characters should show correctly assuming they match your setup.

so:

* set PHP locale to UTF8
* set HTML PAGE (meta tag, header, etc) to UTF8
* be certain the text your are displaying is UTF8 compliant
* be sure database connection and tables are UTF8 compliant (if coming from there)
* be sure all PHP functions that your text pass thru are UTF8 compliant

Smarty makes use of PHP functions under the hood to do its job, so if it works in PHP, is should work here too. Where there are PHP functions that take a character set, UTF8 is the default. Smarty 3 does have a constant defined for default character set, but that is UTF8 by default as well.
Back to top
View user's profile Send private message Visit poster's website
regsnerven
Smarty Rookie


Joined: 26 Mar 2010
Posts: 20

PostPosted: Fri May 07, 2010 11:42 am    Post subject: Reply with quote

I have all this things set up correctly but i can set the local to utf8 in windows because it is not supported in setlocale.

Also i am using the "latest stable version" so i am using 2.6.26 not 3.0. Is that a problem ? Because i think "stable version" means to the user: use this if you totally want to run smarty 100 percent correctly, doesn't it?

Edit:-->
Okay. Just tried it on linux server and it still does not work also with locale set to 'de_DE@euro.UTF8'.
My html code metatag is set to utf8 also.
What do you exactly mean by "utf8 complain" and what do you mean with "your text"? The text which i am complaining about is from your function.
My data is not comming from the db its comming from your html_select_date function.
I am not parsing the text through anything.
I just assign a few vars to it (none that would influence the html_select_date) and then i include the sub template via inlcude in the main template of the section.
Back to top
View user's profile Send private message
elpmis
Smarty Elite


Joined: 07 Jun 2007
Posts: 321

PostPosted: Fri May 07, 2010 12:28 pm    Post subject: Reply with quote

Have you tried to use the escape modifier?

http://www.smarty.net/manual/en/language.modifier.escape.php
Back to top
View user's profile Send private message
regsnerven
Smarty Rookie


Joined: 26 Mar 2010
Posts: 20

PostPosted: Fri May 07, 2010 1:36 pm    Post subject: Reply with quote

How should i use the escape modifier with this function:
Code:

{html_select_date prefix='end_' field_order='DMY' month_empty='Monat' month_extra='disabled=disabled' day_empty='Tag' day_extra='disabled=disabled' start_year='-5' end_year='+5' year_extra='disabled=disabled' time=$date}


I dont have any problems with my var given to the html_select_date function. I have problem with output itself.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7366
Location: Lincoln Nebraska, USA

PostPosted: Fri May 07, 2010 2:14 pm    Post subject: Reply with quote

So just to get this straight, a template as simple as:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>foobar</title>
</head>
<body>
  {html_select_date}
</body>
</html>


Will output messed up utf8 characters?
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7366
Location: Lincoln Nebraska, USA

PostPosted: Fri May 07, 2010 2:23 pm    Post subject: Reply with quote

Another topic on this subject:

http://www.smarty.net/forums/viewtopic.php?t=1577
Back to top
View user's profile Send private message Visit poster's website
regsnerven
Smarty Rookie


Joined: 26 Mar 2010
Posts: 20

PostPosted: Mon May 10, 2010 5:30 pm    Post subject: Reply with quote

Yep it does on windows.

And that topic is not related to this one because the question in that topic is how to do get german output not how to get proper decoded output. ^^
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7366
Location: Lincoln Nebraska, USA

PostPosted: Mon May 10, 2010 7:08 pm    Post subject: Reply with quote

I setup my server with:


Code:
setlocale(LC_ALL, 'de_DE@euro.UTF8', 'de_DE.UTF8', 'deu_deu.UTF8', 'de.UTF8', 'ge.UTF8', 'de_DE@euro', 'de_DE', 'deu_deu', 'de', 'ge');


Then have a template:


Code:
START
{html_select_date}
END


Here is the output:


(see next post)

So how do I replicate your problem?


Last edited by mohrt on Mon May 10, 2010 7:36 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Plugins All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP