Quote from: Andy at Mar 28, 2007, 10:50 AM
Hi Zap, the HTML entity is a product of this forum software. When I made that post and read it afterwards the umlaut-O appeared correctly. Now for some reason it isn’t. So I think that is an SMF issue. If you can tell me how to fix it that would be great. 
As I understand it, SMF changes the character set depending on the language you set for the forums. View the HTML source of your forum pages to see what character set is in the meta tags. That should also be the character set that has been declared in your HTTP headers.
Quote from: Andy at Mar 28, 2007, 10:50 AM
I think it is connected to MODx somehow because if I move the snippet code to a simple PHP file and access the PHP file from my browser, it works perfectly.
MODx also allows you to set your pages’ character set, in Configuration and also as a part of your templates. The two must match, or you will have problems. If the character set declared in your HTTP headers is not the same as the one in your meta tag, expect gobbledygook.
Here is a simple explanation of where character encoding is declared:
http://en.wikipedia.org/wiki/Character_encodings_in_HTML
So I suspect that somehow the character encodings are not matching up. MODx, SMF, and mySQL all should be using the same thing for trouble-free integration. I would experiment with this a bit and see what happens.
Quote from: Andy at Mar 28, 2007, 10:50 AM
I’m using double quotes out of habit (too much C programming) - poor I know, but it should still work.
I wouldn’t go so far as to say it’s "poor". In fact, many PHP programmers say that there’s no appreciable difference in using double quotes most of the time. I haven’t done any tests, but logically it just seems as if it would be more efficient to use single quotes whenever you know that there’s nothing in the string that needs to be parsed (and I always figure the simpler I make things for PHP, the less likely I am to run into something unexpected).
Quote from: Andy at Mar 28, 2007, 10:50 AM
How do I test different character encodings? I’m using nano as my editor. Accented characters appear ok in the PHP files and I can output them to web pages just fine. I can also store them in the MySQL database just fine. Does that indicate that the encodings are correct?
As far as I know, regular PHP text files have no character encoding. You’d have to output this as a header or meta tag from PHP. I think that your server and browser just make assumptions when no character encoding is given, so that’s not a good way to test this for real-world use.
Quote from: Andy at Mar 28, 2007, 10:50 AM
I can return a precalculated value, but this is just a simple test case for my real problem:
$want = 'Öffentlich';
if (!strcmp($string, $want)) {
return 'TOKEN1';
}
return 'TOKEN2';
When this code failed I started to look at what the problem was with strcmp. When I output $want, I saw it was mangled.
This may or may not be related, but it looks to me as if you are using strcmp() as if it were strpos(). The way I understand it, strcmp() always returns a value (-1, 0, or 1). So I would think that you’d always see TOKEN2 using that code, but there may be something I’m missing here...