1*b0d17251Schristos /* 2*b0d17251Schristos * Copyright 2021 The OpenSSL Project Authors. All Rights Reserved. 3*b0d17251Schristos * 4*b0d17251Schristos * Licensed under the Apache License 2.0 (the "License"). You may not use 5*b0d17251Schristos * this file except in compliance with the License. You can obtain a copy 6*b0d17251Schristos * in the file LICENSE in the source distribution or at 7*b0d17251Schristos * https://www.openssl.org/source/license.html 8*b0d17251Schristos */ 9*b0d17251Schristos 10*b0d17251Schristos #ifndef OSSL_INTERNAL_UNICODE_H 11*b0d17251Schristos # define OSSL_INTERNAL_UNICODE_H 12*b0d17251Schristos # pragma once 13*b0d17251Schristos 14*b0d17251Schristos typedef enum { 15*b0d17251Schristos SURROGATE_MIN = 0xd800UL, 16*b0d17251Schristos SURROGATE_MAX = 0xdfffUL, 17*b0d17251Schristos UNICODE_MAX = 0x10ffffUL, 18*b0d17251Schristos UNICODE_LIMIT 19*b0d17251Schristos } UNICODE_CONSTANTS; 20*b0d17251Schristos is_unicode_surrogate(unsigned long value)21*b0d17251Schristosstatic ossl_unused ossl_inline int is_unicode_surrogate(unsigned long value) 22*b0d17251Schristos { 23*b0d17251Schristos return value >= SURROGATE_MIN && value <= SURROGATE_MAX; 24*b0d17251Schristos } 25*b0d17251Schristos is_unicode_valid(unsigned long value)26*b0d17251Schristosstatic ossl_unused ossl_inline int is_unicode_valid(unsigned long value) 27*b0d17251Schristos { 28*b0d17251Schristos return value <= UNICODE_MAX && !is_unicode_surrogate(value); 29*b0d17251Schristos } 30*b0d17251Schristos 31*b0d17251Schristos #endif 32