Sha256: a3e26b4838a82582e8b7aafc7c9c4ff130484df90d53a4dd98fd56d82c1cc44d

Contents?: true

Size: 909 Bytes

Versions: 25

Compression:

Stored size: 909 Bytes

Contents

// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google LLC.  All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd

#include "upb/lex/unicode.h"

// Must be last.
#include "upb/port/def.inc"

int upb_Unicode_ToUTF8(uint32_t cp, char* out) {
  if (cp <= 0x7f) {
    out[0] = cp;
    return 1;
  }
  if (cp <= 0x07ff) {
    out[0] = (cp >> 6) | 0xc0;
    out[1] = (cp & 0x3f) | 0x80;
    return 2;
  }
  if (cp <= 0xffff) {
    out[0] = (cp >> 12) | 0xe0;
    out[1] = ((cp >> 6) & 0x3f) | 0x80;
    out[2] = (cp & 0x3f) | 0x80;
    return 3;
  }
  if (cp <= 0x10ffff) {
    out[0] = (cp >> 18) | 0xf0;
    out[1] = ((cp >> 12) & 0x3f) | 0x80;
    out[2] = ((cp >> 6) & 0x3f) | 0x80;
    out[3] = (cp & 0x3f) | 0x80;
    return 4;
  }
  return 0;
}

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
grpc-1.69.0 third_party/upb/upb/lex/unicode.c
grpc-1.69.0.pre1 third_party/upb/upb/lex/unicode.c
grpc-1.68.1 third_party/upb/upb/lex/unicode.c
grpc-1.67.0 third_party/upb/upb/lex/unicode.c
grpc-1.67.0.pre1 third_party/upb/upb/lex/unicode.c
grpc-1.66.0 third_party/upb/upb/lex/unicode.c
grpc-1.66.0.pre5 third_party/upb/upb/lex/unicode.c
grpc-1.66.0.pre3 third_party/upb/upb/lex/unicode.c
grpc-1.60.2 third_party/upb/upb/lex/unicode.c
grpc-1.61.3 third_party/upb/upb/lex/unicode.c
grpc-1.62.3 third_party/upb/upb/lex/unicode.c
grpc-1.63.2 third_party/upb/upb/lex/unicode.c
grpc-1.64.3 third_party/upb/upb/lex/unicode.c
grpc-1.65.2 third_party/upb/upb/lex/unicode.c
grpc-1.65.1 third_party/upb/upb/lex/unicode.c
grpc-1.65.0 third_party/upb/upb/lex/unicode.c
grpc-1.65.0.pre2 third_party/upb/upb/lex/unicode.c
grpc-1.65.0.pre1 third_party/upb/upb/lex/unicode.c
grpc-1.63.0 third_party/upb/upb/lex/unicode.c
grpc-1.62.0 third_party/upb/upb/lex/unicode.c