TinyPortal

Development => Support => Topic started by: spidernik84 on February 25, 2011, 03:54:25 PM

Title: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: spidernik84 on February 25, 2011, 03:54:25 PM
Link to my site: http://www.versonord.net
SMF version: 1.1.13
TP version: 1.0 RC1
Default Forum Language: Italian-UTF8
Theme name and version: overview light 1111
Browser Name and Version: Opera 11
Mods installed:
SMF 1.0.21 / 1.1.13 Update - 1.0
Country Flags - 1.1.2
Tapatalk SMF Plugin - 1.1.0
TinyPortal - 1.102
Highslide Image Viewer - 1.6
Related Error messages: none

Hello, as stated in the subject I'm having some odd problems with the above configuration.
Versonord.net is an Italian website regarding northern countries, therefore we're writing articles with a lot of special characters like the ones from the Italian and Swedish alphabets (ì,à,è,å,ä).

While the forum can correctly display all characters without trouble, the portal seems to have some trouble after saving each BBC or HTML type article. Sometimes the articles get even truncated, but most of the times the screwed special fonts are the only issue.
The problem persists even switching the default website language to english-utf8.

I browsed and searched the forum but none of the topics seemed to resemble this problem. The most notable one was considered fixed in 2009!

Thanks for your help :).
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: IchBin on February 25, 2011, 10:02:34 PM
There are a couple of bugs in the tracker here on this issue I believe.
http://www.tinyportal.net/index.php?action=projects

I think most of them stem from not using the proper character set when decoding the characters from the database. I have lots of work to do to fix these issues. I hope you can wait until then. :)
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: spidernik84 on February 25, 2011, 10:16:02 PM
Hi, thank you for the answer. Of course I can wait :) Wish I could help, but I'm not a programmer, unfortunately :(.
Could there be any temporary workaround?
Thank you for your support and great work.
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: IchBin on February 26, 2011, 05:04:43 AM
If you are only looking for an articles fix, I could possibly figure that one out for you. Otherwise, hunting down all the different places this needs to be fixed is going to take some time.
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: spidernik84 on February 26, 2011, 08:52:49 AM
No, there would be many articles. I guess I could write the article without special chars, and then swap them in the db via phpmyadmin. Non exactly user friendly, but since we're not adding many articles per week that's feasible.
Thank you anyway, I'll track the buglist.
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: ZarPrime on February 26, 2011, 01:28:36 PM
spidernik84,

I'm not really a programmer either but, in case anyone else sees this topic, this issue seems to have only manifested itself in TinyPortal when the user is using it with SMF 1.1.x, as you are.  Users with an SMF 2.0/TP 1.0 RC1 site do not seem to be affected by this issue.

ZarPrime
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: IchBin on February 26, 2011, 04:23:09 PM
I'll have to do more testing then, thanks Zar.

spidernik84,

I was referring to having the problem in more than one place. Articles is a single point of failure. If I look at the code, it is likely only one place that needs to have the code adjusted to account for the character conversion problem.
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: ZarPrime on February 26, 2011, 05:08:00 PM
Well, I can't say for sure that all works fine with an SMF 2.0 Forum since I don't have a utf8 Forum.  I'm just going on what Agridoc has posted on the Team Board.
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: spidernik84 on February 26, 2011, 05:59:41 PM
Quote from: IchBin on February 26, 2011, 05:04:43 AM
If you are only looking for an articles fix, I could possibly figure that one out for you. Otherwise, hunting down all the different places this needs to be fixed is going to take some time.
Sorry, I totally misinterpreted your post. Yes, I confirm, my interest is mainly to make articles work for now, nothing else. We're not using the shoutbox and the interaction is limited on the webpage (and, quite amazingly, I just discovered that the article comments do not present this problem at all!).

Thank you IchBin :)
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: spidernik84 on March 07, 2011, 02:35:19 PM
Hi, sorry for the delay.
I remember there was a full discussion here regarding the problem, with a solution posted by IchBin, but I see some messages have disappeared!

You wrote I wasn't clear in describing the problem, and I'm sorry. I tried to be as complete as possibile, that's why I provided screenshots also in the deleted messages. My fault for being unclear. I'm writing a detailed description of how to reproduce the problem AFTER the fix provided by IchBin was applied to the code:

1. start creating a new BBC article
2. write the article title and body (the body MUST contain a special char, for example "à","ò","ä").
3. Save the article. As you will see, special characters will be visible without any problem
4. approve and publish the article
5. go to first-page view (your portal's homepage)

The article body will be completely empty.
Body text used:


test

àòù

test




Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: IchBin on March 07, 2011, 05:08:51 PM
Geez.... Server move lost my post... I'll try to take a look at this again soon.
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: spidernik84 on March 17, 2011, 08:43:58 AM
Hello everyone!
Any new development on the UTF8 mystery? :P
I'm still available to try any test you need.
Thank you!
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: IchBin on March 17, 2011, 07:53:41 PM
Nope I only have so much time in the day I can look at things. And since nobody else seems to want to help with these types of issues, you have to wait on me until I can spend the time to look into it. Sorry.
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: sturmkatze on March 18, 2011, 04:01:28 AM
Brad, this has been plaguing me on reenactor.Net too. And it also shoots them into weird places like when I make a fake "m" dash like -- or sometimes just in places where there is a space or paragraph return. And it seems that if you remove them, sometimes they don't come back, but the special characters Do go crazy and it ads, sometimes 5-10 characters.

I hope I am not hijacking, but this is JUST what is driving me nuts. And right when I don't have time to look at it :-(
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: spidernik84 on March 18, 2011, 10:02:43 AM
Quote from: IchBin on March 17, 2011, 07:53:41 PM
Nope I only have so much time in the day I can look at things. And since nobody else seems to want to help with these types of issues, you have to wait on me until I can spend the time to look into it. Sorry.
Ok... I'm really sorry not being to help you solve this problem, I feel useless.
I always wanted to become a programmer as well, but I choose the dark side of computer science (I'm an hardware guy: a networking technician).
I'll keep an eye on the thread and update in case I find something.
PS: if anyone is interested in being paid for solving this, just make an offer and I'll be evaluating with my vice-admin :). The solution will be posted here, of course, no need to keep secrets ;).
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: IchBin on March 22, 2011, 03:21:19 PM
I need to know what your frontpage settings are? What do you have set to display? Articles only, articles and selected forum posts? etc. Depending on which setting you use, changes which code needs to be fixed.
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: spidernik84 on March 22, 2011, 07:48:00 PM
Hi IchBin,
the setting is "Selected topics + articles".
Thank you!
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: IchBin on March 22, 2011, 09:30:38 PM
Open Sources/TPortalAdmin.php
Code (find) Select
tp_query("UPDATE " . $tp_prefix . "articles SET " . $setting . " = '" . htmlentities($newvalue,ENT_QUOTES) . "' WHERE id='" . $where  . "' LIMIT 1", __FILE__, __LINE__);
Code (Replace with) Select
tp_query("UPDATE " . $tp_prefix . "articles SET " . $setting . " = '" . htmlentities($newvalue,ENT_QUOTES, $context['character_set']) . "' WHERE id='" . $where  . "' LIMIT 1", __FILE__, __LINE__);

Open Sources/TPortal.php
Code (find about line #1594) Select
$row['body'] = html_entity_decode($row['body'],ENT_QUOTES);

Code (Replace) Select
$row['body'] = html_entity_decode($row['body'],ENT_QUOTES, $context['character_set']);


Let me know if that doesn't work for you.
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: spidernik84 on March 26, 2011, 11:53:34 AM
Hi. Sorry for the late delay, I've got no internet at home right now :(.

I think you're almost there, but there's still a few glitches:

1. when editing: the body and the query field are now saving the special characters correctly, but the "title" field does not. This happens after filling the TPAdmin edit article form, saving, and displaying the edit article form again.
2. when showing the article in the frontpage: if I'm saving the article without enabling the intro, the article displays correctly. If I'm using the intro, the article intro and the full article linked to the "read more..." are empty. By this, I do not mean that the page does not display, but that the "article body" is empty.

Ask me if I wasn't clear. Thank you.
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: IchBin on March 26, 2011, 04:57:44 PM
1. In TPortal.php find this line right next to the other line you edited for the body.
$row['subject'] = html_entity_decode($row['subject']);'

Replace with:
$row['subject'] = html_entity_decode($row['subject'], ENT_QUOTES, $context['character_set']);

2. I cannot reproduce this problem. If I save an article and select to use the intro, the article shows the intro and the read more link. If I then click on the read more link I am taken to the article with the full text from the article. Works as I would expect it to.
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: spidernik84 on March 26, 2011, 05:39:40 PM
I modified the files exactly as you indicated, but the title still gets corrupted and the body shows as empty.
I double checked the modifications and even started from scratch.

Since I want to be sure I didn't make a mistake, would you be so kind to attach the files modified by you? Thank you :)
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: IchBin on March 28, 2011, 07:39:38 PM
I have not modified any files. I have only looked at the code and given you what things I would fix. Let me take another look.

ETA:
Code (find in Sources/TPSubs.php) Select
function tp_sanitize($value, $strict=false)
{
return htmlentities(strip_tags($value),ENT_QUOTES);
}


Code (replace with) Select
function tp_sanitize($value, $strict=false)
{
        global $context;
return htmlentities(strip_tags($value), ENT_QUOTES, $context['character_set']);
}
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: sturmkatze on May 20, 2011, 06:13:12 AM
Has this been fixed? I have a real problem w/ pages that foreign words on them, such as this one: http://www.reenactor.net/forums/index.php/page,180.html (http://www.reenactor.net/forums/index.php/page,180.html) Anything like this, umlauts, whatever, throws weird code. Any answers yet???
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: IchBin on May 20, 2011, 05:42:39 PM
It should be fixed in the code I have updated for TP1 RC2.
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: sturmkatze on May 21, 2011, 04:53:33 AM
That being the one I have t wait for dragooon to add? :P All dis stuff being causin' ma brains to melt.
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: Kike_GL on June 03, 2011, 07:32:28 AM
My forum is in Spanish_latin-utf8 and I have the same problem. My solution is to use special HTML codes.

http://www.utexas.edu/learn/html/spchar.html
Title: Re: Special UTF8 characters not showing correctly in articles (swedish and italian)
Post by: IchBin on June 03, 2011, 04:06:00 PM
Should be fixed in the next release which is coming up soon.