I am in the need of defining html classes from content, so pretty much every char could be used. According to html reference I may use cdata, so I should not run into problems. I figure though, that css and/or javascript/jquery won’t play nicely with that.
Anyone has experience with what chars can be used without problems or if there is a function/plugin/.. that tidies the class names, so that they are usable?
css classnames must be the usual identifiers (http://www.w3.org/TR/CSS21/syndata.html#characters)
Javascript doesn’t mind, since you will use classnames as Strings. So you can use any character as far as javascript is concerned.
If you want to strip your classnames down to the usable css subset, a simple regexp should be enough. If you want to encode your classnames into the same subset, it will be a little tougher, but I suppose you can try to Base64-encode them. Here are some jQuery plugins for base64 encoding/decoding.