decodeURI関数の動作でブラウザ判別

function getBrowserNameByDecodeURI() {
  //Firefox's decodeURI decodes percent-encoded U+FFFF and U+FFFE as U+FFFD
  if (decodeURI("%EF%BF%BF") == "\uFFFD") {
      try {
        //see http://d.hatena.ne.jp/masa141421356/20091009
        decodeURI("%F0%81%80%80");
        return "Firefox 3.5 or older";
      } catch (e) {
        return "Firefox 3.6";
      }
  }
  try {
    if (decodeURI("%C0%80")=="%C0%80") { //Opera's bug DSK-298518
      return "Opera 10.x or Older";
    }
    return "IE";
  } catch (e) {
    //ECMAScript5 requires to throw URIError for percent-encoded overlong UTF-8
    try {
      //ECMAScript5 also requires to throw URIError for
      //single surrogate code.
      //But, some browsers do not throw URIError.
      // see http://d.hatena.ne.jp/Constellation/20110530/1306759498
      if (decodeURI("%ED%A0%80")=="\uFFFD") {
          return "Opera 11.60";
      }
      return "Google Chrome (current)or Opera 11.0-11.50 or Firefox 4-7";
    } catch (e) {
      //If implementation of decodeURI is ECMAScript5 compliant, this code will be executed.
      return "Safari or Firefox 8(or later) or Google Chrome (after V8 issue 1415 fixed)"; 
    }
  }
}
2011/06/12 追記

id:Constellation さんからsurrogate code を使った判別方法を教えていただいたので判別部分を追加しました。

2011/10/27追記

サロゲートエリアの問題の修正パッチが入ったりしたのでその分を反映

2011/12/21追記

Opera11.60の動作が変わったのでその分を反映