Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

       <-- these characters keep appearing!


Go to End


7 Posts   10663 Views

Avatar
swaiba

Forum Moderator, 1899 Posts

16 May 2011 at 11:27pm

Edited: 16/05/2011 11:34pm

I can remove them with...

return utf8_decode ($content);

... but why do these things keep appearing on sites? how can I rid myself of them for ever?

please help! it is driving me CRAZY!

Avatar
moloko_man

Community Member, 72 Posts

17 May 2011 at 3:43am

I only see them crop up when I'm in Dev mode and I'm outputting stuff with Debug::show();
I would assume there is a character in one of the base classes that you'll have to find.

Now that I think about it, I've seen stuff like this crop up when my co-worker uses Dreamweaver to edit php files with the wysiwyg editor, you'll have to zap the gremlins.

Avatar
swaiba

Forum Moderator, 1899 Posts

17 May 2011 at 9:23am

Thanks, I did kinda throw it out there without much info... made me remember teh chinese outsurcers that left chinese comments in the code (amongst other things...)

It is coming from the database it gets into the content, page titles, etc.
I think it is after I run a mysqldump and then restore it (all via Lunix shell and without transferring the file out the box), but today just upgrading a site to 2.4.5 and running a db build did it this time...

any advice now I've been a bit more specific - any ideas? config settings? db settings?
all suggestions welcome :)

Avatar
swaiba

Forum Moderator, 1899 Posts

19 May 2011 at 3:55am

Thanks to FinBoWa on IRC...

using

SHOW VARIABLES LIKE 'character_set%';
SHOW VARIABLES LIKE 'collation%';

to see that my db was...

collation_connection utf8_general_ci
collation_database latin1_swedish_ci
collation_server latin1_swedish_ci

Then after running the following SQL (from http://muzso.hu/2008/04/09/how-to-change-the-character-set-and-or-collation-in-a-mysql-database-for-all-tables-and-c)

SELECT CONCAT('ALTER TABLE `', t.`TABLE_SCHEMA`, '`.`', t.`TABLE_NAME`, '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;') as stmt
FROM `information_schema`.`TABLES` t
WHERE 1
AND t.`TABLE_SCHEMA` = 'sm_sandbox'
ORDER BY 1

the collation is this...

collation_connection utf8_general_ci
collation_database utf8_general_ci
collation_server latin1_swedish_ci

I am removing the characters for the last time (hopefully) as my db should now be setup correctly, if not I'll update this thread...

Avatar
jocuri

Community Member, 3 Posts

23 May 2011 at 2:42am

I think you could also try to filter the input, and everytime someone introduces this kind of letters you will replace them with what ever you want..

Avatar
swaiba

Forum Moderator, 1899 Posts

23 May 2011 at 8:31pm

Hi jocuri,

Thank you for the reply - in my case everyone is adding characters like... ', £ or just a space (for all I can tell) and then after a dev build or a backup and restore the strange characters appear. I did strip these characters when displaying "Content" - but it affects every HTMLText and Text field (again for as far as I can tell) - How would I easily filter it from all of these do you think? Create a custom HTMLTextField and TextField class? I'd be concerned that that is the wrong way to go about it...

Avatar
swaiba

Forum Moderator, 1899 Posts

21 June 2011 at 2:02am

so this now seems to have settled down... the solution was to add the following vhost.conf in the conf folder of the vhost...

<Directory /var/www/vhosts/NAMEOFDOMAIN/httpdocs/>
AddDefulatCharset UTF-8
</Directory>