PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - ext/json - utf8_to_utf16.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 15 15 100.0 %
Date: 2014-07-13 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* utf8_to_utf16.c */
       2             : 
       3             : /* 2005-12-25 */
       4             : 
       5             : /*
       6             : Copyright (c) 2005 JSON.org
       7             : 
       8             : Permission is hereby granted, free of charge, to any person obtaining a copy
       9             : of this software and associated documentation files (the "Software"), to deal
      10             : in the Software without restriction, including without limitation the rights
      11             : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      12             : copies of the Software, and to permit persons to whom the Software is
      13             : furnished to do so, subject to the following conditions:
      14             : 
      15             : The above copyright notice and this permission notice shall be included in all
      16             : copies or substantial portions of the Software.
      17             : 
      18             : The Software shall be used for Good, not Evil.
      19             : 
      20             : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      21             : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      22             : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      23             : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      24             : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      25             : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
      26             : SOFTWARE.
      27             : */
      28             : 
      29             : #include "utf8_to_utf16.h"
      30             : #include "utf8_decode.h"
      31             : 
      32             : int 
      33         482 : utf8_to_utf16(unsigned short w[], char p[], int length) 
      34             : {
      35             :     int c;
      36         482 :     int the_index = 0;
      37             :     json_utf8_decode utf8;
      38             :     
      39         482 :     utf8_decode_init(&utf8, p, length);
      40             :     for (;;) {
      41       18905 :         c = utf8_decode_next(&utf8);
      42       18905 :         if (c < 0) {
      43         482 :             return (c == UTF8_END) ? the_index : UTF8_ERROR;
      44             :         }
      45       18423 :         if (c < 0x10000) {
      46       18406 :             w[the_index] = (unsigned short)c;
      47       18406 :             the_index += 1;
      48             :         } else {
      49          17 :             c -= 0x10000;
      50          17 :             w[the_index] = (unsigned short)(0xD800 | (c >> 10));
      51          17 :             the_index += 1;
      52          17 :             w[the_index] = (unsigned short)(0xDC00 | (c & 0x3FF));
      53          17 :             the_index += 1;
      54             :         }
      55       18423 :     }
      56             : }

Generated by: LCOV version 1.10

Generated at Sun, 13 Jul 2014 23:57:51 +0000 (8 days ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.