"""Selected Unicode character locator; no deletion, full bidi/security/rendering claim."""
import unicodedata as U,hashlib,json,sys
SELECTED={0x00a0,0x00ad,0x200b,0x200c,0x200d,0x200e,0x200f,0x202a,0x202b,0x202c,0x202d,0x202e,0x2060,0x2066,0x2067,0x2068,0x2069,0xfeff,0xfe0e,0xfe0f}
def inspect(text):
    if not isinstance(text,str)or len(text)>4096:raise ValueError('bounded Unicode string4096codepoints')
    raw=text.encode('utf-8','strict');rows=[];byte=0;units=0
    for i,ch in enumerate(text):
        if ord(ch)in SELECTED:rows.append({'codepoint_index_zero_based':i,'utf8_byte_start_zero_based':byte,'utf16_unit_start_zero_based':units,'code':'U+'+format(ord(ch),'04X'),'escaped':json.dumps(ch,ensure_ascii=True),'name':U.name(ch,'UNNAMED'),'category':U.category(ch),'bidi_class':U.bidirectional(ch)})
        byte+=len(ch.encode('utf-8'));units+=len(ch.encode('utf-16-le'))//2
    return {'sha256':hashlib.sha256(raw).hexdigest(),'original_text_json_escaped':json.dumps(text,ensure_ascii=True),'codepoints':len(text),'utf8_bytes':len(raw),'selected_occurrences':rows}
def demo():
    text='🙂ا\u0654می\u200cرویم|الف\u00a0ب|x\u200by|\u2067ID-7\u2069|A\u200eB|❤\ufe0f|x\u2060y';before=text.encode();out=inspect(text)
    expected=['U+200C','U+00A0','U+200B','U+2067','U+2069','U+200E','U+FE0F','U+2060'];assert [x['code']for x in out['selected_occurrences']]==expected and text.encode()==before
    for row in out['selected_occurrences']:
        i=row['codepoint_index_zero_based'];assert row['utf8_byte_start_zero_based']==len(text[:i].encode())and row['utf16_unit_start_zero_based']==len(text[:i].encode('utf-16-le'))//2
    assert out['selected_occurrences'][0]['codepoint_index_zero_based']==5 and out['selected_occurrences'][0]['utf16_unit_start_zero_based']==6
    repeat=inspect('x\u200cy\u200cz');assert [r['codepoint_index_zero_based']for r in repeat['selected_occurrences']]==[1,3]
    assert not inspect('')['selected_occurrences']and not inspect('abc \n فارسی')['selected_occurrences']
    return {'python_version':sys.version.split()[0],'unicode_database_version':U.unidata_version,'authored':out,'repeated_same_codepoint':repeat,'empty_and_ordinary_space_newline_no_match':True,'original_bytes_unchanged':True,'scope':'Small explicit20-codepoint set, not all invisible/default-ignorable/whitespace characters or visual bidi/security/semantic checker. Names/properties from actual runtimeUCD. Positions zero-based codepoint/UTF8/UTF16; combining/nonBMP before match tested. Output uses escaped notation for controls; no normalization or auto-delete.'}
if __name__=='__main__':print(json.dumps(demo(),ensure_ascii=True,indent=2))
