ZhangZhihui's Blog  

In Notepad++, the NBSP stands for Non-Breaking Space, which is a special whitespace character.

  • Unicode code point: U+00A0

  • HTML entity:  

  • Unlike a normal space (U+0020), a non-breaking space prevents automatic line breaks at its position.

  • In Notepad++, when you enable View → Show Symbol → Show All Characters, it is usually displayed as NBSP (or sometimes as a small dot or highlighted space depending on your settings).

So in short:
👉 NBSP = non-breaking space character (U+00A0)

Would you like me to also show you how to search and replace all NBSPs with normal spaces in Notepad++?

 

Yes, I would. Thanks.
 
ChatGPT said:

Perfect 👍 Here’s how you can find and replace NBSP (non-breaking space, U+00A0) with a normal space in Notepad++:


Method 1: Directly Copy & Replace

  1. Copy an actual NBSP from your text (the one showing as NBSP in Notepad++).

  2. Open Search → Replace… (Ctrl + H).

  3. In Find what, paste the NBSP character.

  4. In Replace with, press the spacebar once (normal space).

  5. Click Replace All.


Method 2: Use Extended Search with \xA0

  1. Open Search → Replace… (Ctrl + H).

  2. At the bottom, select Search Mode → Extended (\n, \r, \t, \0, \x...).

  3. In Find what, enter:

     
    \xA0

    (this is the hex code for NBSP).

  4. In Replace with, enter a normal space.

  5. Click Replace All.


Method 3: Using Regex (if mixed whitespace issues)

  1. Open Search → Replace….

  2. Select Search Mode → Regular expression.

  3. In Find what, enter:

     
    \x{00A0}
  4. In Replace with, enter a normal space.

  5. Replace all.


👉 Usually, Method 2 (\xA0) is the easiest.

 

What's the difference between an NBSP and a normal space? How was NBSPs introduced in a text file?
 
ChatGPT said:

Great question 👌 Let’s break it down:


🔹 Difference Between NBSP and Normal Space

FeatureNormal Space (U+0020)Non-Breaking Space NBSP (U+00A0)
Appearance Looks like a space Looks the same as a space
Line breaking Allows text to wrap/line break Prevents line breaking at that position
Width Standard width, depends on font Usually the same width as normal space (but can differ in some fonts)
Encoding ASCII-compatible (0x20 in most encodings) Unicode only (0xA0 in Latin-1, UTF-8: 0xC2 0xA0)
Display in Notepad++ Shows as a blank (or dot if symbols visible) Shows as NBSP when symbols visible

👉 So they look identical, but NBSP carries a special “don’t break here” rule.


🔹 How NBSPs Get Into a Text File

NBSPs usually appear unintentionally. Common sources:

  1. Copy-paste from websites or documents

    • In HTML,   is used to insert extra spaces (e.g., for indentation or alignment).

    • When you copy text from a webpage, those  s turn into Unicode U+00A0.

  2. Word processors (MS Word, Google Docs, etc.)

    • They sometimes insert NBSP automatically to prevent breaking between numbers and units (100 kg, 10 AM) or between initials in names (J. K. Rowling).

  3. PDF or scanned documents

    • Text extracted from PDFs often contains NBSPs instead of regular spaces.

  4. Keyboard shortcuts

    • Some keyboard layouts (e.g., French AZERTY, Mac Option+Space) allow typing NBSP directly.


✅ So, in short:

  • Normal space = regular blank, breaks naturally.

  • NBSP = looks the same, but glues words together.

  • They sneak into text mostly via copy-paste from HTML, Word, or PDF.

 

posted on 2025-08-26 08:25  ZhangZhihuiAAA  阅读(13)  评论(0)    收藏  举报