Truncation
Quá trình cắt văn bản theo độ dài chỉ định. Được sử dụng để vừa vùng hiển thị hoặc giới hạn cột cơ sở dữ liệu.
Cắt ngắn là quá trình cắt văn bản theo độ dài chỉ định. It is used whenever text needs to be shortened to fit constraints such as display area limits, database column sizes, and API response sizes. From web UI design to backend data processing, truncation is a fundamental operation that appears across all layers of software development.
Kỹ thuật cắt ngắn UI phổ biến nhất là thêm dấu ba chấm (...). Trong CSS, kết hợp text-overflow: ellipsis with overflow: hidden and white-space: nowrap achieves automatic single-line text truncation. Multi-line truncation uses the -webkit-line-clamp property. When truncating strings in JavaScript, rather than simply using str.slice(0, maxLength), care should be taken to cut at the last space position to avoid breaking words mid-way. CSS layout practical guides cover this in detail.
Cắt ngắn văn bản tiếng Nhật có những cân nhắc riêng. Cutting in the middle of surrogate pairs (emoji or certain kanji) causes garbled text. Cutting within combining characters (base character + diacritical marks) breaks display. In JavaScript, splitting into code points using Array.from(str) or [...str] before truncating avoids these issues. Additionally, cutting just before punctuation marks like "。" or "、" creates an unnatural impression, so punctuation-aware truncation is preferable.
Cắt ngắn công cụ tìm kiếm cũng là chủ đề quan trọng. Google's meta description display is truncated to approximately 120 characters on desktop and 70 on mobile. Title tags are also truncated based on display width, making it an SEO fundamental to place important keywords at the beginning. Since truncated portions are invisible to search users, content structure must prioritize information accordingly.
Cắt ngắn cơ sở dữ liệu cần chú ý đặc biệt vì có thể dẫn đến mất dữ liệu. Inserting more than 255 characters into a VARCHAR(255) column in MySQL causes an error in strict mode or silent truncation otherwise. In UTF-8 environments, where one character occupies 3-4 bytes, it is important not to confuse byte-based limits with character-based limits. SEO practical guides also explain optimal meta description lengths.
Về đếm ký tự, cắt ngắn là mặt trái của "character limits." The typical workflow is checking current character count with a counting tool and truncating when the limit is exceeded. Verifying that truncated text retains meaning and that the character count including the ellipsis stays within limits is essential in practice.