Comments (6)
good point.
For the record I was trying to find a solution to the particular issue. Iām not against adding mbstring
.
from laminas-cache.
Actually you may not need the mbstring
extension:
if (strlen($string) != strlen(utf8_decode($string)))
{
echo 'string is unicode';
}
from laminas-cache.
@ghostwriter As written in Slack, this would then require ext-xml
.
from laminas-cache.
@boesing right.
also came up with this:
if (strlen($string) !== strlen(html_entity_decode($string, ENT_QUOTES , 'ISO-8859-1')))
{
echo 'string is unicode';
}
// another method
html_entity_decode
is an internal function. https://3v4l.org/UZOM1
var_dump(in_array('html_entity_decode', get_defined_functions()['internal'])); // bool(true)
from laminas-cache.
The main thing I dont like here is, that strlen
is slow depending on the key length. Here, we have to do it twice.
There were performance checks in #154 (comment) regarding performance and thus I'd like to avoid doing it twice. Thus, requiring mbstring seems the most proper way of veryfing the length of a string with a minimal footprint.
from laminas-cache.
Closing this with the rationale, that allowing keys longer than 65534
will lead to performance problems when validating cache keys. Another reason is, that mb_strlen
does not return the byte length but the string length.
UTF-8 characters which consume 4-bytes should be treated as 4 characters
but with mb_strlen
they're treated as 1 character
.
from laminas-cache.
Related Issues (20)
- PHP 8.1: `SimpleCacheDecorator#convertIterableToArray` converts float to integer array keys HOT 1
- Documentation: Add integration examples for `mezzio` and `laminas-mvc` HOT 10
- Upgrade to PHP 8 does not work because of dependencies requirements HOT 3
- Migration to PHP 8.0 with replace leads to unexpected errors HOT 8
- [RFC]: PSR compatibility via dedicated satellites HOT 1
- [RFC]: remove conflict with symfony/console HOT 5
- Cannot add laminas cache to my project. HOT 3
- PHP 8.1.1 support HOT 6
- A cache storage implementation is required, while the CaptureCache pattern does not require one HOT 2
- CacheItemPoolDecorator does not properly handle multiple unsaved deferred items HOT 3
- RFC: Configure AdapterPluginManager from the config HOT 9
- Use `Clock`-Interface (PSR-20) in `PSR-6` `CacheItem`
- Dependency Dashboard
- psr/cache V3 and psr/simple-cache V3 compatibilities HOT 1
- laminas-cache is still using Laminas\Cache\StorageFactory::factory() which no longer exists HOT 6
- Provide native support for PSR-20 HOT 1
- [RFC]: Detach serializer plugin from `laminas-serializer` HOT 4
- Add `cache` configuration key documentation HOT 3
- Update `vimeo/psalm` to v5.16 once available HOT 1
- Remove virtual package requirement `laminas/laminas-cache-storage-implementation` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laminas-cache.