Reference: This is a self-answered question. It was meant to share the knowledge, Q&A style.
How do I detect the type of end of line character in PHP?
PS: I’ve been writing this code from scratch for too long now, so I decided to share it on SO, plus, I’m sure someone will find ways for improvement.
Notes:
Needs to somehow know that we may be on an exotic system like ZX8x (since ASCII x76 is a regular letter)@radu raised a good point, in my case, it’s not worth the effort to handle ZX8x systems nicely.mb_detect_eol()(multibyte) anddetect_eol()