Welcome Guest, Not a member yet? Register   Sign In
Weird thing happening with UTF-8 file type...
#1

[eluser]jleequeen[/eluser]
Hey Everyone,

I've spent the last two days debugging my code and for the life of me could not figure out why I was getting this whitespace at the top of my XHTML file. Finally, late last night, I figured it out. Now, I'm just wondering why it is. I know this is not a CI question, but maybe someone can enlighten me.

At first, I thought it might be some stray code in my view, but then another view that was exactly the same except for a couple lines of code (that wouldn't cause that problem) worked just fine. I combed through my controller file and could find nothing that would cause it. And I had commented out any models or helper files that it called, so it couldn't have been one of those. Anyway, finally through some stroke of luck, I noticed when I saved the controller file in my IDE, that it was saving the file as ANSI when I did a save as. When I create a new file from the File/New menu, the editor was set by default to save new files in UTF-8. I normally don't create new files from the File menu, I typically create through copying an existing file, or in the project tree. So, I narrowed it down to the controller file that was saved in UTF-8 (which i must have created through the File menu at some point). Anyway, I saved the controller in ANSI, and whala, the whitespace was gone. I have no idea why. I know UTF-8 is the recommended file type, but, if I can't figure out why this whitespace was there, then I'll have to stick with ANSI.

Any ideas? Never had an issue like this before.
#2

[eluser]BrianDHall[/eluser]
I have found UTF-8 to be highly recommended - and a significant pain in my ass. When I load older projects in they choke on weird ass errors and request me to provide transliteration - seems the single comma (') mark causes me problems.

Also I found problems with the dash (-). Even now I have a piece of my code where in my acceptable characters regex it has two dashes that look exactly alike - but their character codes are different, and if I remove either of them my site stops working in a few select places.

Pain in the ass! Character encoding blows monkey eggs - with IDE's, window/unix/mac differences, and databases all having their own preferences and ideas and conversion pains...I say phewey!
#3

[eluser]BrianDHall[/eluser]
[quote author="Sock Puppet" date="1254442083"]And you're monolingual, I'm prepared to bet. Now throw a few other languages and their associated weird characters into the ring, and thing start to get interesting real quick. That said: once you solve these issues you solve them once and for all. From that point on you can deal with any character the web, your users or whoever might throw at you. So, phewey indeed, but there's not alternative, really ...[/quote]

Oh yes, I fully agree on all points. I still use UTF-8, and I should have mentioned most IDEs have a "show non-printable characters" option which you might find useful in situations like this.

I'd prefer it didn't suck - but I still use utf-general-ci for my MySQL, UTF-8 UNIX files in my IDE (on windows, as I deploy onto linux just incase), and hate opening old projects and getting that damn transliteration string.

Hey, "If English was good enough for Jesus, it's good enough for me." Darn world and its insistence that there is more to the alphabet than the english-version of romanized A-Z/a-z characters.

This is what happens when we let just anyone use a computer - the audacity, that english speaking people should have to consider the fact that other humans exist Wink
#4

[eluser]n0xie[/eluser]
[quote author="BrianDHall" date="1254442359"]
Hey, "If English was good enough for Jesus, it's good enough for me."[/quote]
That's so wrong on so many many levels even if it was just sarcasm.
#5

[eluser]InsiteFX[/eluser]
I wrote and posted a document on here and also some other users have.

One of the biggest problems is MySQL even if you do this

) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

You will not get the COLLATE=utf8_unicode_ci!

MySQL will default to latin1_swedish_ci collation!

To fix this problem in phpAdmin after creating the database you need to go to the operations tab and scroll to the bottom and then set the COLLATION to utf8_unicode_ci or whatever you want.

TEST IT:

Go ahead and create new database like shown above with the COLLATE=utf8_unicode_ci then add a table and view it and look at the collation!

also if you use the utf8_unicode_ci it will see more langages then utf8_general_ci! But is bigger in size.

Enjoy
InsiteFX
#6

[eluser]BrianDHall[/eluser]
[quote author="n0xie" date="1254490755"][quote author="BrianDHall" date="1254442359"]
Hey, "If English was good enough for Jesus, it's good enough for me."[/quote]
That's so wrong on so many many levels even if it was just sarcasm.[/quote]

Isn't it fantastic? I heard it as perhaps the greatest example in our generation of "cultural ignorance". It's just go so many elements rapped up in it, it is like a Gordian Knot of all that is wrong with self-centered ignorance that ignores the existence of other countries and their peoples.

I live in the american south-east in the "bible belt", so I live amongst people who make me believe it might actually be a real quote Smile

If you google it you'll find that it is a quote of not entirely known authenticity - I think it an urban legend in origin, but its just so elequently wrong I can't help but repeat it.

In the words of Eddie Izzard, "...you do know there are other countries?"




Theme © iAndrew 2016 - Forum software by © MyBB