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