/*
 * 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
 */

const Utils = require("./../../../unisharp/Utils");

const PdfObject = require("./PdfObject");

class PdfName extends PdfObject {
    
    constructor() {
        super();
        this.name = null;
    }
    
    toStringEx(lev) {
        return this.name;
    }
    
    isSimple(lev) {
        return true;
    }
    
    write(s) {
        s.writeByte('/'.charCodeAt(0));
        for (const ch of this.name) {
            if ("%()<>[]{}/#".indexOf(ch) >= 0 || (ch.charCodeAt(0)) <= 0x20) {
                let hex = Utils.correctToString((ch.charCodeAt(0)).toString(16).toUpperCase(), 2, true);
                s.writeByte('#'.charCodeAt(0));
                s.writeByte(hex.charCodeAt(0));
                s.writeByte(hex.charCodeAt(1));
            }
            else 
                s.writeByte(ch.charCodeAt(0));
        }
    }
    
    static _new228(_arg1) {
        let res = new PdfName();
        res.name = _arg1;
        return res;
    }
}


module.exports = PdfName