Welcome Guest, Not a member yet? Register   Sign In
Problem with german "Umlaut"
#1

Hello,

I have a problem with building a substring.
The scenario is that a string should be cut to a fixed length, if it is longer then n characters.
The problem is for example with the string "Rettungshundeanhänger" the substring would end exactly at the "ä".
Unfortunatly CI cuts the special char representation or the unicode represantation of the character, so that there results an unknown character... (example under http://feuerwehr-bs.de/aktuelles/einsatz/2692 in the right darkgrey frame).

Any idea how to solve this issue?

KR
Habib
Reply
#2

I think you'll need to use PHP's multi-byte string functions instead of the regular ones.

http://php.net/manual/en/ref.mbstring.php

Sorry I can't be more helpful. I've never worked with special characters before.
Hey, don't work without a PHP debugger. Several free IDEs have this features built in. Two are NetBeans and CodeLobster. Without a debugger, it's like you're driving with a blindfold on -- you are going to crash!
Reply
#3

(This post was last modified: 02-22-2015, 04:39 PM by ivantcholakov. Edit Reason: Avoiding a smiley. )

For UTF-8 string operations I use a ported class from Kohana: https://github.com/ivantcholakov/codeigniter-utf8

Code:
substr($string, 0, 10) becomes UTF8::substr($string, 0, 10) and etc.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB