Forums > MaxMSP

Slice text with special characters

April 1, 2013 | 4:01 pm

Hi,

I want to slice a text, which includes special characters (like ö ü §) after every 8 characters.
Hi,my name is Ögiögi. – > Hi,my na me is Ög iögi

I tried atoi, which gives me a list with numbers, that I can split. Unfortunately some of the special characters have two numbers in the list. A reliable character slicing isn’t possible. Any ideas? Thanks!


April 1, 2013 | 7:59 pm

if you’re not interested in re-combining the words later on (or if the special characters don’t matter) then you can simply filter out the extra characters:

the ASCII for umlaut ( ¨ ) is 195, so you could simply add a [zl filter 195] after [atoi], before splitting with [zl slice].

Otherwise you might need to check [regexp], but I’m not very experienced with it so I can’t help you there!


April 1, 2013 | 9:58 pm

I want to recombine them later and the special characters mater :/ Hmm…


April 2, 2013 | 7:37 pm

interessting problem. i tryed it with js and it has the same problem. for example it will report a string length of 4 for "ÖÖ".
a regexp approach is (……..) and use outlet3 but how to get the remainding chars at the end which are less than 8?


April 3, 2013 | 2:49 pm

this seems to work [regexp (..?.?.?.?.?.?.?)]
Get a list with the slices from outlet 3. O.


February 1, 2014 | 2:37 pm

it seems like something has changed since then. js now gives me the correct string length, even with special characters included. O.

function string(arg)
{

var len = jsarguments[1] || 10;

outlet(0, arg.substring(0, len));
}


Viewing 6 posts - 1 through 6 (of 6 total)