[Development] RFC: Proposal for a semi-radical change in Qt APIs taking strings

Marc Mutz marc.mutz at kdab.com
Thu Oct 15 16:50:00 CEST 2015


On Thursday 15 October 2015 14:52:46 Konstantin Ritt wrote:
> For everything but US-ASCII / Latin-1, UTF-8 isn't faster than UTF-16 (feel
> free to compare their complexity against UTF-32).
> And why "pure Chinese signs" again? Did you ever look into the Unicode's
> Scripts.txt [1], for example? It clearly shows UTF-16 covers [almost] all
> spoken languages, without any performance hits (in compare to UTF-8), and
> all we have to pay is an extra byte per every Base Latin character (in
> compare to UTF-8, again).
> 
> [1] http://www.unicode.org/Public/8.0.0/ucd/Scripts.txt

What everyone is referring to here is this:

<!DOCTYPE html>
<html lang="zh">
  <meta charset="utf-8">
  <title>Google</title>
  <style>
    html { background: #fff; margin: 0 1em; }
    body { font: .8125em/1.5 arial, sans-serif; text-align: center; }
    h1 { font-size: 1.5em; font-weight: normal; margin: 1em 0 0; }
    p#footer { color: #767676; font-size: .77em; }
    p#footer a { background: url(//www.google.cn/intl/zh-
CN_cn/images/cn_icp.gif) top right no-repeat; padding: 5px 20px 5px 0; }
    ul { margin: 2em; padding: 0; }
    li { display: inline; padding: 0 2em; }
    div { -moz-border-radius: 20px; -webkit-border-radius: 20px; border: 1px 
solid #ccc; border-radius: 20px; margin: 2em auto 1em; max-width: 650px; min-
width: 544px; }
    div:hover, div:hover * { cursor: pointer; }
    div:hover { border-color: #999; }
    div p { margin: .5em 0 1.5em; }
    img { border: 0; }
  </style>
  <div>
    <a href="http://www.google.com.hk/webhp?hl=zh-CN&sourceid=cnhp">
      <img src="//www.google.cn/landing/cnexp/google-search.png" alt="Google" 
width="586" height="257">
    </a>
    <h1><a href="http://www.google.com.hk/webhp?hl=zh-
CN&sourceid=cnhp"><strong id="target">google.com.hk</strong></a></h1>
    <p>请收藏我们的网址
  </div>
  <ul>
    <li><a href="http://translate.google.cn/?sourceid=cnhp">翻译</a>
  </ul>
  <p id="footer">©2011 - <a href="http://www.miibeian.gov.cn/">ICP证合字
B2-20070004号</a>
  <script>
    var gcn=gcn||
{};gcn.IS_IMAGES=(/images\.google\.cn/.exec(window.location)||
window.location.hash=='#images'||
window.location.hash=='images');gcn.HOMEPAGE_DEST='http://www.google.com.hk/webhp?hl=zh-
CN&sourceid=cnhp';gcn.IMAGES_DEST='http://images.google.com.hk/imghp?'+'hl=zh-
CN&sourceid=cnhp';gcn.DEST_URL=gcn.IS_IMAGES?gcn.IMAGES_DEST:gcn.HOMEPAGE_DEST;gcn.READABLE_HOMEPAGE_URL='google.com.hk';gcn.READABLE_IMAGES_URL='images.google.com.hk';gcn.redirectIfLocationHasQueryParams=function()
{if(window.location.search&&/google\.cn/.exec(window.location)&&!/webhp/.exec(window.location))
{window.location=String(window.location).replace('google.cn','google.com.hk')}}
();gcn.replaceHrefsWithImagesUrl=function(){if(gcn.IS_IMAGES){var 
a=document.getElementsByTagName('a');for(var i=0,len=a.length;i<len;i++)
{if(a[i].href==gcn.HOMEPAGE_DEST){a[i].href=gcn.IMAGES_DEST}}}}
();gcn.listen=function(a,e,b){if(a.addEventListener)
{a.addEventListener(e,b,false)}else if(a.attachEvent){var 
r=a.attachEvent('on'+e,b);return r}};gcn.stopDefaultAndProp=function(e)
{if(e&&e.preventDefault){e.preventDefault()}else 
if(window.event&&window.event.returnValue)
{window.eventReturnValue=false;return false}if(e&&e.stopPropagation)
{e.stopPropagation()}else if(window.event&&window.event.cancelBubble)
{window.event.cancelBubble=true;return 
false}};gcn.resetChildElements=function(a){var b=a.childNodes;for(var 
i=0,len=b.length;i<len;i++)
{gcn.listen(b[i],'click',gcn.stopDefaultAndProp)}};gcn.redirect=function()
{window.location=gcn.DEST_URL};gcn.setInnerHtmlInEl=function(a)
{if(gcn.IS_IMAGES){var b=document.getElementById(a);if(b)
{b.innerHTML=b.innerHTML.replace(gcn.READABLE_HOMEPAGE_URL,gcn.READABLE_IMAGES_URL)}}};
    gcn.listen(document, 'click', gcn.redirect);
    gcn.setInnerHtmlInEl('target');
  </script>

This is google.cn. Please count the ratio of us-ascii to non-us-ascii letters. 
See also, say, https://blog.mozilla.org/dmandelin/2008/02/14/wtf-16/

Thanks,
Marc

-- 
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt Experts



More information about the Development mailing list