unicode & os detection

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

unicode & os detection

Post by daedalus__ »

is os detection reliable? there are a couple of unicode characters i would like to use on my website. they work great on linux systems and are available on windows through the wing and web dings fonts. i found some pretty fonts that i could probably include using css but i would like to avoid that feature if possible. im not sure how reliable os detection is though. in the tests i have done i haven't been able to produce results that were unreliable but thats just my system who knows. and just fmi what about uncommon operating systems like ibm ones?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: unicode & os detection

Post by requinix »

A very simple OS detection would be like

Code: Select all

if (empty($_SERVER["HTTP_USER_AGENT"])) {
    // can't know
} else if (stripos($_SERVER["HTTP_USER_AGENT"], "Win")) {
    // probably windows
} else if (stripos($_SERVER["HTTP_USER_AGENT"], "Linux") || stripos($_SERVER["HTTP_USER_AGENT"], "Unix")) {
    // probably 'nix
} else if (stripos($_SERVER["HTTP_USER_AGENT"], "Mac")) {
    // probably mac
} else {
    // don't know - spider?
}
That's the answer to your question.

The answer to your problem is more along the lines of using images instead of characters or strings.
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: unicode & os detection

Post by daedalus__ »

images are a lot less fun. and i understand how to code it i just dont know how reliable it is. i know that browser detection can be icky sometimes so i figured the same may apply to this.
Post Reply