in reply to dynamically detect code page

I notice that some lines in your example contain "GER-" and some contain "JAP-". Could you use that as an indicator for which lines contain which characters?

As far as detecting the Japanese encoding of a string, Jcode might be useful. (See the getcode sub.)

Like duckyd alluded to, if you have any control over the writing of the file, writing it in a single encoding -- utf-8 -- could make reading it a lot easier.