Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Detect Encoding Laravel Package

onnov/detect-encoding

Fast Cyrillic text encoding detector for PHP to replace unreliable mb_detect_encoding. Identifies Windows-1251, KOI8-R, ISO-8859-5 (optionally IBM866/MacCyrillic) using code page ranges, with high accuracy even on short strings and very large texts.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Legacy Data Migration: Accelerate migration of legacy systems (e.g., Soviet-era databases, old Windows applications) by reliably detecting and converting encodings like windows-1251 or koi8-r, reducing manual intervention and data corruption risks.
  • Globalization (i18n) Expansion: Enable seamless support for Cyrillic, Eastern European, and other non-Latin scripts in Laravel applications targeting markets like Russia, Ukraine, or Bulgaria, improving user experience and compliance.
  • Data Integrity for Critical Systems: Mitigate risks in applications handling sensitive or high-stakes text (e.g., legal documents, medical records, or financial data) where encoding misinterpretation could lead to errors or compliance violations.
  • Performance Optimization: Replace slow or unreliable encoding detection in high-traffic Laravel APIs or batch processing jobs, reducing latency and improving scalability for text-heavy workloads.
  • Cost-Effective Technical Debt Reduction: Avoid custom development or third-party SaaS solutions for encoding detection, leveraging this lightweight, MIT-licensed package to modernize legacy codebases without additional costs.
  • ETL Pipeline Reliability: Ensure accurate encoding detection during extract-transform-load (ETL) processes, particularly when ingesting data from external sources with mixed or unknown encodings (e.g., partner APIs, user uploads).
  • Localization Features: Support dynamic encoding detection for multilingual content management systems (CMS) or e-commerce platforms where product descriptions or user-generated content may use non-standard encodings.

When to Consider This Package

Adopt when:

  • Your Laravel application processes text from legacy systems (e.g., databases, files, or APIs) where mb_detect_encoding fails to accurately identify encodings like windows-1251, koi8-r, or iso-8859-5.
  • You need high accuracy for short texts (≤30 characters), where mb_detect_encoding’s reliability drops significantly for certain encodings.
  • Performance is critical, and you require faster encoding detection for large volumes of text (e.g., batch processing, real-time APIs).
  • Your application targets Cyrillic or Eastern European markets and must handle non-Latin scripts reliably.
  • You are migrating from PHP 7.x to 8.x and want to future-proof encoding detection logic without relying on deprecated or unstable native functions.
  • Data integrity is non-negotiable, and encoding misdetection could lead to legal, financial, or reputational risks.

Look elsewhere if:

  • Your use case is strictly UTF-8, and modern PHP’s default encoding handling (or mb_detect_encoding in PHP 8.x+) meets your needs.
  • You require support for exotic encodings (e.g., Big5, Shift_JIS, or UTF-16/UTF-32), which this package does not cover.
  • Maintenance is a concern, as the last release was in 2021. If this is critical to production, consider forking or extending the package.
  • You’re processing streaming or extremely large files (e.g., GBs of text) and need chunked or buffered detection (this package is optimized for in-memory strings).
  • Your team lacks the bandwidth to validate edge cases (e.g., mixed encodings, noise in text) or integrate a third-party dependency.

How to Pitch It (Stakeholders)

For Executives: *"This package resolves a critical technical gap in our ability to accurately process text from legacy systems and global markets. For example, misdetecting windows-1251 as UTF-8 could corrupt Cyrillic emails or documents, leading to customer dissatisfaction or compliance issues. By adopting this lightweight, MIT-licensed solution, we can:

  • Reduce manual effort in data migration projects by automating encoding detection.
  • Improve scalability for high-volume text processing, cutting latency by up to 10x.
  • Expand into new markets (e.g., Eastern Europe) without custom development costs. The implementation is low-risk, with minimal dev effort and no ongoing costs—just a direct replacement for unreliable native functions."*

For Engineering: *"The onnov/detect-encoding package provides a drop-in replacement for mb_detect_encoding with 99.9%+ accuracy for Cyrillic and legacy encodings—critical for our [legacy migration/data pipeline/API]. Here’s why it’s a win:

  • Reliability: Fixes false positives/negatives for encodings like windows-1251 (where mb_detect_encoding fails for short texts).
  • Performance: Benchmarks show 10x faster detection for large texts (e.g., 1.3M characters in 0.00096 sec).
  • Low Risk: MIT license, no dependencies, and minimal boilerplate. Replace mb_detect_encoding($text, 'UTF-8,WINDOWS-1251,...') with:
    $detector = new \Onnov\DetectEncoding\EncodingDetector();
    $encoding = $detector->getEncoding($text);
    
  • Extensible: Supports custom encodings and whitelisting for edge cases. Proposed Integration:
  1. Pilot in [Module X] (e.g., CSV imports or API payloads).
  2. Wrap in a service layer for consistency (e.g., app/Services/EncodingDetector).
  3. Add to Laravel’s service container for DI. Effort: 1–2 dev days for core systems. Let’s validate accuracy with our test datasets first."*

For Product/Design: *"This package enables us to safely expand into markets where text encoding is a barrier (e.g., Russia, Ukraine). For example:

  • E-commerce: Accurately display product descriptions in Cyrillic without corruption.
  • Customer Support: Parse and respond to emails/documents in legacy encodings.
  • Localization: Automatically detect and convert user-generated content for global audiences. No changes to UI/UX—this is purely a backend reliability upgrade. We’ll prioritize integration where encoding issues are most painful (e.g., [Legacy System Y] or [API Z])."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity