1. Список говнокодов пользователя lobovkin

    Всего: 1

  2. PHP / Говнокод #8147

    +163

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    switch(true) {
                case ((0x7F & $bytes) == $bytes):
                    // this case should never be reached, because we are in ASCII range
                    // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
                    return chr(0x7F & $bytes);
    
                case (0x07FF & $bytes) == $bytes:
                    // return a 2-byte UTF-8 character
                    // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
                    return chr(0xC0 | (($bytes >> 6) & 0x1F))
                         . chr(0x80 | ($bytes & 0x3F));
    
                case (0xFFFF & $bytes) == $bytes:
                    // return a 3-byte UTF-8 character
                    // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
                    return chr(0xE0 | (($bytes >> 12) & 0x0F))
                         . chr(0x80 | (($bytes >> 6) & 0x3F))
                         . chr(0x80 | ($bytes & 0x3F));
            }

    В одной из реализаций JSON.php

    * @package Services_JSON
    * @author Michal Migurski <[email protected]>
    * @author Matt Knapp <mdknapp[at]gmail[dot]com>
    * @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
    * @copyright 2005 Michal Migurski
    * @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
    * @license http://www.opensource.org/licenses/bsd-license.php
    * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198

    lobovkin, 10 Октября 2011

    Комментарии (15)