<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[A Workaround for 0xFF and NUL bytes to Hex]]></title><description><![CDATA[<p dir="auto">Re: <a href="/topic/25390">Unicode 'ÿ' – problem converting to Hex 'FF'</a></p>
<p dir="auto">Wow, I can’t believe it’s been 2 years since I ran into this issue…anyway I finally figured out a working fix.</p>
<p dir="auto">To fix the signed integer anomaly, we apply a bitwise AND mask (&amp; 0xFF). This converts Scintilla’s negative integers back into true unsigned byte values (0 to 255) before string formatting. The entire conversion happens entirely in memory and replaces the target range in a single, atomic undo action.</p>
<p dir="auto"><strong>How to Use:</strong><br />
Open a binary file, highlight the bytes you want to convert, then run the script. All ÿ and NUL bytes will successfully be converted.</p>
<p dir="auto">Cheers :)</p>
<pre><code># -*- coding: utf-8 -*-
# Notepad++ PythonScript: Convert selected bytes to hex, skip 0xFF (ÿ) and 0x00 (NUL). Substite with FF and 00 on second pass.

from Npp import *

def main():
    editor.beginUndoAction()
    try:
        start = editor.getSelectionStart()
        end = editor.getSelectionEnd()
        if start == end:
            return

        hex_parts = []
        
        for pos in range(start, end):
            raw_b = editor.getCharAt(pos)
            b = raw_b &amp; 0xFF  # Keep the unsigned 0-255 byte conversion
                
            if b == 0xFF:
                # Direct conversion: No more placeholder strings needed!
                hex_parts.append("FF")  
            else:
                # Flawless 2-digit Hex formatting for NUL (00) and other bytes
                hex_parts.append("%02X" % b)  
                
        # Write the finalized, pure hex block directly to the document
        editor.setTargetStart(start)
        editor.setTargetEnd(end)
        editor.replaceTarget(''.join(hex_parts))
        
    finally:
        editor.endUndoAction()

if __name__ == '__main__':
    main()
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/topic/27583/a-workaround-for-0xff-and-nul-bytes-to-hex</link><generator>RSS for Node</generator><lastBuildDate>Sun, 21 Jun 2026 18:52:50 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/27583.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 21 Jun 2026 15:31:23 GMT</pubDate><ttl>60</ttl></channel></rss>