/*
 * SDK Pullenti Unitext, version 4.33, fabruary 2026. Copyright (c) 2013-2026, Pullenti. All rights reserved. 
 * Non-Commercial Freeware and Commercial Software. 
 * This class is generated using the converter UniSharping (www.unisharping.ru) from Pullenti C# project. 
 * The latest version of the code is available on the site www.pullenti.ru
 */

using System;
using System.IO;

namespace Pullenti.Unitext.Internal.Pdf
{
    public class PdfName : PdfObject
    {
        public string Name;
        public override string ToStringEx(int lev)
        {
            return Name;
        }
        public override bool IsSimple(int lev)
        {
            return true;
        }
        public override void Write(Stream s)
        {
            s.WriteByte((byte)'/');
            foreach (char ch in Name) 
            {
                if ("%()<>[]{}/#".IndexOf(ch) >= 0 || ch <= 0x20) 
                {
                    string hex = ((int)ch).ToString("X02");
                    s.WriteByte((byte)'#');
                    s.WriteByte((byte)hex[0]);
                    s.WriteByte((byte)hex[1]);
                }
                else 
                    s.WriteByte((byte)ch);
            }
        }
    }
}