9 ms·
Is the use of “utf8=✓” preferable to “utf8=true”?
- jasonlingx 14y agoCorrect me if I'm wrong but I think forms in Rails do this by default.
- mosburger 14y agoThey do. IIRC they used to use a Unicode snowman instead of a checkmark, but it was changed as the snowman wasn't deemed "enterprisey enough" or something.
- griffindy 14y agothey did use a snowman before, though I can't find the commit where they changed it. EDIT: found the commit with some git log magic - https://github.com/rails/rails/commit/c616089 https://github.com/rails/rails/commit/c616089
- nicholassmith 14y agoMaybe when a service/product/framework etc hits a specific point in it's lifecycle (when it's trying to be enterprisey for example), we can say that it's melted the snowman.
- xanadohnt 14y agoI mean ... this is one of the funniest comments I've read on HN. I will be diligent in adopting this into my nerd vernacular.
- nicholassmith 14y agoIf it ends up as a thing I'll be surprised and proud.
- mmahemoff 14y agoI prefer the tick. It's self-documenting which makes it more useful and that also makes it amusing in its own way.
- dllthomas 14y agoIt's partially self documenting. As mentioned elsewhere, there's a vague implication that putting something else there could mean "don't use utf8", where if you put the utf8 X character that corresponds to the check you are still asking for utf8. edited to add: This seems related to a problem various "try to sound like English" programming languages (e.g. Inform) have, where it is easy to assume invalid syntax will be valid because it's valid English.
- garethadams 14y agoYou're not wrong. I'm surprised my answer's got so much attention to be honest, because it's so common in Rails apps.
- jerf 14y agoSo, of course, the opposite of that is utf8="✘", right? Hmmm... there's something wrong with that idea, but I can't quite put my finger on it....
- buro9 14y agoYou didn't read the article. This isn't a config file, this is the query string of a URL, or more importantly the POST data of a form. From the article: > By default, older versions of IE (<=8) will submit form data in Latin-1 encoding if possible. By including a character that can't be expressed in Latin-1, IE is forced to use UTF-8 encoding for its form submissions, which simplifies various backend processes, for example database persistence. > If the parameter was instead utf8=true then this wouldn't trigger the UTF-8 encoding in these browsers
- IgorPartola 14y agoUnder what case would IE use Latin 1 when there are UTF-8 characters that should be encoded? I seem to be missing the actual effect it's having.
- jpenner 14y agoSome accented characters are in Latin-1, like ç or é.
- jerf 14y agoYes, that took me a moment too, but Latin-1 is an 8-bit ASCII, and UTF-8 only encompasses 7-bit ASCII. Note I have to say an 8-bit ASCII, because there are numerous 8-bit ASCII encodings.
- ygra 14y agoASCII is a 7-bit code. Latin 1 uses 8 bits and therefore cannot be ASCII. It's a superset of ASCII, though.
- derleth 14y ago> UTF-8 only encompasses 7-bit ASCII What? This is wrong. UTF-8 encodes a lot more than just ASCII. UTF-8 is compatible with ASCII in that all of the characters ASCII and Unicode have in common are represented the same way in ASCII and UTF-8. Going beyond ASCII involves the introduction of multi-byte representations in UTF-8, and that takes you smoothly (that is, no surrogate pairs) out into the entire rest of Unicode. As a bonus, it's always possible to verify that a given string of bytes is valid UTF-8, given that there is a nontrivial structure imposed on UTF-8 multi-byte encodings that is very unlikely to occur by chance in any non-UTF-8 sequence of bytes.
- Firehed 14y agoI think the point was that anything above 7-bit ASCII will be represented differently in Latin-1 vs UTF-8; i.e. ¢ (U+00A2) is rendered as 0xA2 in Latin1 and 0xC2A2 in UTF-8 - and 0xC2A2 in Latin1 will be displayed as ¢. It gets far worse in 3-byte UTF8 characters, but I don't believe any of them exist natively in Latin1 (see: euro symbol) Assuming I'm reading these various character tables right, at least ;) So a more accurate version of what you quoted would be "UTF-8 and Latin-1 only overlap for 7-bit ASCII"
- grey-area 14y agoI've often wondered if they could get rid of this entirely in rails by enclosing it in conditional comments, so that it is only included in forms sent by older IE: <!--[if lt IE 8]><input name="utf8" type="hidden" value="✓" /><![endif]--> Has anyone experimented with doing that?
- riffraff 14y agowhat would the gain be?
- simonw 14y agoIt would be less likely to leak out in to a GET string and confuse people.
- Dylan16807 14y agoIt also gives people more info to search with.
- grey-area 14y agoFor simple get queries like a search the utf param is visible in the url, so it can be ugly. There are ways round this of course, but as Rails is inserting it automatically, it would make sense if they only did it for the one browser which requires it.
- ollysb 14y agoSorry to be so meta, but what on earth was the point of extracting programmers.stackexchange.com from stackoverflow.com? Is this why so many questions get closed as being "off topic" on stackoverflow now? </rant>
- Tyrannosaurs 14y agoThe original idea was to make it a bit of a waste bin for all the softer questions which had relevance to programmers but weren't directly related to programming. Remember the SO model takes a pretty hard line on what's relevant to try and minimise the noise and this was seen as a solution to what to do with questions which were interesting and semi-relevant but seemed too much like noise to many. After while Programmers was becoming a bit too much of a dumping ground so tightened up the rules to make it less random and chatty and more of a valid site in it's own right for topics around software development but which are not directly programming related.
- xhrpost 14y agoI believe the guidelines divide the two as objective vs. subjective. Stackoverflow (Objective): Why does this code give me a syntax error? Programmers (Subjective): What programming methodology best fits my project and team?
- mratzloff 14y agoUsually subjective questions are now closed as "not constructive".
- aviraldg 14y agoBest way to detect a Ruby on Rails app ;)
- randomdata 14y agoNavigating to /500.html is another good way. Most people do not remove it and most other frameworks/people do not create it in the first place.
- charliesome 14y agoAnother good one is sending a query string of '?a=1&a[a]=1'. 500s Rack applications.
- bitwize 14y agoUmmmm, false. I'm going to go with false.
- gweinberg 14y agoIf the point of the field is just to make ie work correctly, wouldn't it be more appropriate to leave utf8 out of the name and write something like "ie=💩"?
- Zakharov 14y agoIf you want to check whether a browser supports a feature, it's preferable to check whether the browser supports the feature instead of whether the browser is a browser that supports the feature. The latter can cause problems when dealing with an unexpected browser.
- tlrobinson 14y agoDoes IE not respect the "accept-charset" attribute on form elements?
- gpvos 14y agoOnly partially; read the other comments.