PHP: Convert "squiggles and hooks" text to normal english/latin alphabet letters

Abstract: Convert HTML entities and strip Unicode diacritics from PHP strings to produce clean ASCII text.

Created: 2026-09-18 by

To convert "squiggles and hooks" text to normal English or Latin alphabet letters in PHP, you must first identify the specific encoding or obfuscation method used. If the text is HTML-encoded (like "), use html_entity_decode(). For Unicode normalization of accented characters, apply Normalizer::normalize() with the Normalizer::FORM_D form to strip diacritics, ensuring the output matches standard ASCII requirements.

Understanding Squiggles and Hooks Text

The term "squiggles and hooks" is not a standard technical definition but typically refers to two distinct types of character transformations that obscure plain text. The first type involves HTML entities or special symbols where characters like quotes, ampersands, or less-than signs are replaced by their code equivalents. For example, a double quote might appear as " or an apostrophe as '. This is common when text is passed through web forms or stored in databases that escape special characters for security. The second type involves Unicode normalization issues, particularly with accented characters. Letters such as é, ñ, or ü contain "hooks" (diacritical marks) that make them visually distinct from their base Latin counterparts e, n, and u. When systems expect strict ASCII input, these accented characters can cause errors or search mismatches. Converting these requires decomposing the characters into their base letter and combining mark, then removing the combining marks entirely. Identifying which type of transformation you are dealing with is crucial because the solution differs significantly. If your string contains sequences starting with & followed by alphanumeric codes, it is likely HTML entity encoding. If your string looks like normal text but contains non-English letters that need to be stripped of accents, you are dealing with Unicode normalization.

Decoding HTML Entities

When text contains HTML entities, the most straightforward way to revert it to readable text is using PHP's built-in html_entity_decode() function. This function converts all applicable HTML entities to their corresponding characters. It handles both named entities like & and numeric entities like A. You should always specify the character encoding to ensure accurate conversion. UTF-8 is the standard for modern web applications, so passing UTF-8 as the second argument is recommended. Additionally, specifying the flags parameter allows you to control how quotes are handled. Using ENT_QUOTES ensures that both single and double quotes are converted, which is often necessary when parsing JSON or structured data that has been escaped. Here is how you implement this:
$encoded_text = "Hello "World" & Goodbye";
$decoded_text = html_entity_decode($encoded_text, ENT_QUOTES | ENT_HTML5, 'UTF-8');
echo $decoded_text; // Outputs: Hello "World" & Goodbye
If you encounter mixed content where some parts are entities and others are raw text, this function remains safe as it only transforms recognized entity sequences. It does not alter plain ASCII characters, making it a robust first step in any cleaning pipeline.

Stripping Diacritics with Normalizer

For text containing accented characters, the Normalizer class from the Internationalization (Intl) extension is the correct tool. This class implements the Unicode Standard Annex #15, which defines compatibility decomposition and canonical composition. To remove "hooks," you need to decompose the characters into their base form and combining marks, then filter out the marks. First, check if the Intl extension is installed on your server, as it is required for this operation. You can verify this by calling extension_loaded('intl'). Once confirmed, use the Normalizer::normalize() static method. Pass your string and the constant Normalizer::FORM_D as arguments. This form performs canonical decomposition, splitting combined characters like é into e and an acute accent mark. After decomposition, you must remove the combining marks. You can achieve this using a regular expression that targets Unicode categories for combining marks. The pattern /[\x{0300}-\x{036F}]/u covers most common diacritical marks. Applying preg_replace with this pattern leaves you with the clean, base Latin letters.
$text_with_accents = "Café résumé naïve";
$decomposed = Normalizer::normalize($text_with_accents, Normalizer::FORM_D);
$clean_text = preg_replace('/[\x{0300}-\x{036F}]/u', '', $decomposed);
echo $clean_text; // Outputs: Cafe resume naive
This approach preserves the integrity of the underlying letters while removing the visual modifiers. It is essential for indexing, searching, or generating URLs where accented characters are undesirable.

Handling Mixed Encodings

In real-world scenarios, you may face strings that contain both HTML entities and accented characters. A robust solution combines both techniques. Start by decoding HTML entities to reveal the actual Unicode characters. Then, apply the normalization process to strip any remaining diacritics. This two-step process ensures that the final output is pure ASCII text, suitable for legacy systems or strict validation rules. Consider the complexity of different languages. While the regex for combining marks works well for Western European languages, other scripts may require different handling. For instance, Chinese or Japanese characters do not have diacritics in the same sense, so the normalization step will leave them largely unchanged unless they are specifically composed of base and mark components. Always test your conversion logic with sample data representative of your user base. If you need to preserve certain accented characters for display purposes while stripping them only for internal processing, keep the original string separate. Store the normalized version in a dedicated field for indexing or URL generation, while keeping the human-readable version intact for UI rendering. This separation prevents data loss and maintains usability across different system components. For more complex text manipulation tasks involving patterns and numbers, you might find related resources useful. See our guide on RegEx to find TEXT plus up to 6 numbers for advanced extraction needs.

Frequently Asked Questions

What happens if the Intl extension is not installed?

You cannot use the Normalizer class without the Intl extension enabled in your PHP configuration. You must install the package via your package manager (e.g., apt-get install php-intl) and restart your web server. Alternatively, you can use a third-party library like symfony/polyfill-intl-normalizer if you cannot modify server settings.

Can I convert Cyrillic or Greek text to Latin?

The methods described above only strip diacritics from existing Latin characters; they do not transliterate completely different alphabets. Converting Cyrillic or Greek to Latin requires a dedicated transliteration algorithm or library, such as transliterator_transliterate(), which maps characters based on phonetic similarity rather than just removing accents.

Why does my encoded text still look weird after html_entity_decode?

If the text remains unreadable, it may not be HTML entities but rather URL encoding or raw byte sequences. Check if the string starts with % instead of &. If so, use urldecode() instead. Also, ensure your PHP file and database connection are both set to UTF-8 to prevent mojibake.

Is it safe to remove all non-ASCII characters?

Removing all non-ASCII characters can destroy meaning in many languages. For example, German umlauts or Spanish tildes carry semantic weight. Only strip diacritics if your use case specifically demands ASCII-only output, such as for SEO-friendly slugs. Otherwise, preserve the original characters to maintain linguistic accuracy.

How do I handle emojis in this process?

Emojis are multi-byte Unicode characters and are not affected by diacritic stripping or basic HTML entity decoding. If you need to remove emojis, you must use a specific regex pattern targeting emoji Unicode ranges. Be cautious, as removing emojis might break social media integrations or user-generated content displays.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More