Log in

View Full Version : Foreign Language characters in filenames


Pages : [1] 2

IanB
26th April 2006, 04:19
Unicode guru's your help please!

A tracker bug report, [ 1407212 ] Problem with spanish unicode characters in filenames (https://sourceforge.net/tracker/?func=detail&atid=482673&aid=1407212&group_id=57023), has me a little perplexed.

Most of AviSynth uses 8 bits character file system calls like fopen and as such relies on the system default conversion of filenames to unicode.

DirectShowSource() is the one exception and it explicitly uses "MultiByteToWideChar(CP_ACP, ..." to do the
filename unicode translation.

To the best of my reseach the system default translation should be equivalent to this code, but for Sven Rieke and naugas and probably many others they are not.

Enlightment required please :confused:

Richard Berg
28th April 2006, 23:03
Are string variables in the script language Unicode?

IanB
29th April 2006, 07:52
No, the entire world is 8 bit. The text files that hold the script, the file i/o calls that read it, the memory array that hold the data, etc.

Richard Berg
29th April 2006, 11:28
8 bit is ok if it's treated as UTF-8 (not plain ASCII). I think you'll have to use platform APIs for that to happen, though, not ANSI stuff like fopen.

IanB
29th April 2006, 13:58
Okay who are you and what have you done with the real Richard Berg. :D

No seriously, the fundamental question is what translation does Windows use for ANSI file system calls like fopen?

I assumed it was based on the current active code page, but obviously it is not. Can we help these users without recodeing half the internals.

foxyshadis
29th April 2006, 17:37
fopen is overloaded depending on what you defined in the way of multibyte support.


TCHAR.H routine _UNICODE & _MBCS not defined _MBCS defined _UNICODE defined
_tfopen fopen fopen _wfopen


If it still uses the plain ansi version, it uses setlocale() and defaults to the system default code page. So if it isn't defaulting something bizarre is happening, like a setlocale() in a header. reference (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_CRT_Code_pages.asp)

I found nothing about fopen being translated any differently from anything else, so I assume there's nothing special with its conversion.

IanB
30th April 2006, 06:15
@foxyshadis,

No fopen and like are never overloaded. The TCHAR versions are the ones that are overloaded like _tfopen which will map to either fopen or _wfopen. Other calls like CreateFile map to either CreateFileW(LPCWSTR.... or CreateFileA(LPCSTR.... depending on whether UNICODE is defined.

However thank's for the reference, it pushed me thru another documentation iteration of code page stuff and I may be a little closer to understanding what is happening.

Current guess is that on the systems with a problem they are using the OEM code page instead of the ANSI code page for the unicode translation or maybe vice versa.

It is more likely to be fopen inappropriatly using the OEM code page because DSS works and it explicitly does a manual translation using the system default ANSI code page. (which incidently is probably wrong, the code probably should be this ... AreFileApisANSI() ? CP_ACP :CP_OEMCP ...)

Whatever it is, the path from the persons fingers to final data block representing the filename inside the OS is not consistent.

Short of converting the internals to use WCHAR's everywhere AND forcing the .AVS scripts to be 16bit UNICODE text files, I cannot see how to resolve this. I need someone with practicle experience that actually suffers the problem to step up.

IanB
2nd May 2006, 13:50
Maybe some of our friends that use non "US English" Windows can ask around for a little guidance and report back.

Fizick
2nd May 2006, 18:57
I am not Unicode guru, but I am one of your friends that use non "US English" Windows. :)

I have no any problem with Russian (Cyrillic) names of avi files, log files, or avs scripts in Win2k or WinXP.
AVS file must be created in ANSI code, of course, by Notepad, etc.
But if I try create AVS file in console application editor like Far Manager in OEM codepage, then Russian names of AVI files in AVS script are not good ("not found" error), of course.

Some not-related info. Some time ago I consider try to do language wrapper of Avisynth functions to Russian.
For example, instead of BlankClip I can create function:

Function ПустойКлип (clip ..., ...)
{
BlankClip(......)
}
ПустойКлип()

This produce Error: expected a function name

But I can use some non-capital Russian letters, if first symbol of function name is Latin or _:

Function _пустойклип (......)
{
BlankClip(......)
}
_пустойклип()

Some Russian letters produce "unexpected character" error.
Why?
For clip names first symbol may be Russian too.
Sorry for off-topic. :)

IanB
3rd November 2007, 00:51
Ping! Here is another example :- Avisynth and japanese characters

IanB
17th November 2007, 07:57
Ping! And here is yet another example :- Avisynth + Unicode

dukey
17th November 2007, 13:51
to fix avisynth with funky file names ..
without looking at the code
just use _wfopen
or rather use _tfopen and define _UNICODE and maybe UNICODE as well. Then replace char with TCHAR.

that still leaves the problem though of the scripts being ascii 7 or 8 bit :p

IanB
17th November 2007, 22:51
... the problem though of the scripts being ascii 8 bitThe problem you are looking to fix is currently at core\main.cpp@588env->Invoke("Import", szScriptName);so your your last statement is slightly wrong, it is not the remainder of the problem, it is the whole problem


One possibility is to switch to using CP_UTF8 in place of the current CP_ACP and CP_OEMCP. (Ding! Richard your last comment suddenly makes sense now) Now this will not be transparent, you will need to find text editors and be able to configure them to output UTF-8 text files for scripts.

I could provide ANSItoUTF8, ACPtoUTF8 and OEMtoUTF8 script functions to ease the pain a little. i.e.AviSource(ANSItoUTF8("ПустойКлип"))

I could also flip the system code page to CP_UTF8 (65001) on entry to Avisynth and restore it on exit to assist plugins that do fopen, etc, calls.

Thorts?

Fizick
18th November 2007, 02:30
AviSource("ПустойКлип.avi", UTF8=true) would be more compatible with existent scripts,

Leak
18th November 2007, 03:22
AviSource("ПустойКлип.avi", UTF8=true) would be more compatible with existent scripts,
Looks a bit weird IMHO, having to tack on a parameter for this.

How about AviSource and AviSourceUTF8? :D

IanB
18th November 2007, 04:41
@Leak, The blind following the blind straight over a cliff :P

@Fizick, You seem to have missed the issue, AviSource() is but 1 example of the whole problem. i.e. Import(), DirectShowSource(), Mpeg2Source, WavSource(), Nic*Audio(), etc, etc, etc, ...

@All,

Neither AviSource(UTF8=True) or AviSourceUTF8() type thinking addresses the issue, which is what is the true UNICODE filename string intended by the user in the 8bit text of the script. As I said earlier the path between the users fingers and the UNICODE file system must not be ambiguous.

Currently we use the "fopen" class of ansi i/o library calls, which to the best of my research so far internally do MultiBytetoWideChar(AreFileApisANSI() ? CP_ACP : CP_OEMCP, ...) calls to get a UNICODE string for the tail end kernel calls. This mostly work for users who can nail down their Code Page environment. It comes unstuck as soon as you need more than 1 Code Page.

UTF-8 is an encoding scheme to represent UNICODE characters unambiguously in 8 bit data. By assuming that scripts are UTF-8, it solves all my problems dealing with a UNICODE based file system behind the I/O library calls.

But UTF-8 is an encoding scheme it is not a very friendly replacement for the warm safe language based Ansi Code Page world.

As a native english speaker whose scripts consist entirely of chars [32..126] I will not ever see a problem. Everybody else will have serious issues!

More Thorts?

foxyshadis
18th November 2007, 04:47
You can start by looking for a BOM in the parser, that should be a very good indicator of how upper characters should be translated. (Table of BOMs (http://unicode.org/faq/utf_bom.html#22).) All unicode-aware text editors are supposed to use it, but if it's not present, as in many files, it'll be more difficult, but what about starting by assuming it's UTF-8, translating that back to UCS-16 internally, if that fails (or if it succeeds but the file isn't found) assume it's some code page and retry the open with that translation? Further translation attempts up to you.

I just ask because anything extra in the script is going to be a big pain.

That doesn't work for 3rd party plugins, obvs, and it'll cause some more complexity internally, but as you know there isn't really a way you can translate everything to one format (like UCS-16) without some things failing or people not realizing they're working in one encoding and not another.

[P]ako
18th November 2007, 04:51
I had a similar problem. I had the antialiasing script (aaa) saved as unicode, maybe because of the accent mark on Didé's nick. Avisynth couldn't load the script at all, the error was pointing an issue with the line importing the script. I solved the issue by converting said script to UTF-8.

IanB
18th November 2007, 09:14
@foxyshadis,

Looking for a BOM doesn't help. It's cart before the horse. The scripts are plain 8 bit text. To look for the BOM you have to start with the assumption that the file is UTF, the BOM then tells you which flavour of UTF.

Here's a UTF-8 BOM "" .... oh, it doesn't do anything.

@[P]ako,

Yes trying to feed raw UNICODE in to something expecting ASCII chokes big time, every second byte is a NULL (as in NULL terminated strings). Converting to any 8 bit code page would have masked the problem.


@All,

At last some inspiration! :D

I zap all the fopen/createfileA type calls and replace them with _wfopen/createfileW type calls. Plus I manually use MultiBytetoWideChar(AVSCodePage, ...) to do the char to wchar translations.

I set AVSCodePage to (AreFileApisANSI() ? CP_ACP : CP_OEMCP) after script verb "Import" has opened the script file but before it parses it. i.e. it _wfopen's the script file using the existing AVSCodePage translation, then resets AVSCodePage to it's default value.

I provide a script verb to let the user specify the code page to be used for char to wchar translations in subsequent script verbs that result in unicode system or library calls.

In the AVIFileOpenW implementation code for the Avisynth handler I do a WideChartoMultiByte(CP_UTF8, ...), set AVSCodePage=CP_UTF8 and then do the env->Invoke("Import", ...) [this is why I need to keep resetting AVSCodePage]

Maybe I can allow an .AVSI script to set a default default code page.

Many more thorts please?

DonQ
20th November 2007, 17:32
Read two first bytes from any source/script/include file in binary mode. If they present BOM (were they FF FE and FE FF?), consider this file UTF8, otherwise ASCII. Of course you need convert both files to same format afterwards, UTF8 or UCS16 for example.

This corresponds exactly to how Notepad saves [new] files - if it detects any character not from current ANSI code page, it automatically adds BOM and saves file in UTF8.

IanB
20th November 2007, 22:48
Hmm, keep the ruminations coming :DBytes Encoding Form
FE FF UTF-16, big-endian
FF FE UTF-16, little-endian
EF BB BF UTF-8If I see FF FE or FE FF as the first 2 bytes of a file I will know it is going to be 16bit unicode and I will NOT be able to do anything with it (maybe not so).

However if I saw the EF BB BF sequence I could set the default AVSCodePage to UTF-8, I am not aware of editors that do this, but I could easily add the processing in anticipation. Effectively treating it as if the script had started
AVSCodePage("UTF-8") ... [Is this transparent?]

As for the "maybe not so" I could easily do a WideChartoMultiByte(CP_UTF8, ...) and set AVSCodePage=CP_UTF8 in the file read code of Import() ... [Is this transparent?]

Consider your wishes carefully.

I will not implement anything that will break the existing 7 bit ascii behaviour of Avisynth.

I will resist implementing anything that will break existing 8 bit codepage behaviour that currently works satisfactorily.

I will not implement anything that will prevent a future pure 16bit unicode implementation of Avisynth.

foxyshadis
21st November 2007, 00:40
Why do you want to transform back to UTF-8, instead of dropping internal ascii parsing all together? Convert to UCS-16 based on either the UTF marked by the BOM or by the default code page in use. Convert back to 8-bit for string arguments based on the code page only. If people want to use unicode without a BOM, or something, perhaps use the python method - assume everything is 8-bit unless a string is preceded by u, as in u"ангел смерти".

Define a new character to replace 's' ('u'?) for unicode or utf-8 or whatever you want, and then convert all characters to that, for any filters that want to support it. Tell people that they need two filter definitions, one with s and one with u, and show them how to build callbacks using with WideChartoMultiByte(CP_ACP, ...) to hand to a WCHAR constructor.

Avisynth will prefer the u definition over the s definition.

Supporting legacy ASCII and Unicode behavior is not an easy problem, and any easy workarounds are unfortunately likely to make a later conversion to full unicode impossible without breaking something.

IanB
21st November 2007, 01:29
Because converting Avisynth to unicode is going to be very very hard and I am lazy :p

Just saying scripts are UTF-8 period! would be exceedingly easy, but I am not that much of an arsehole, so I look for simple ways to maintain the status quo compatibility wise and give Foreign Language users some way to move forward.

dukey
21st November 2007, 13:52
UTF-8 seems like a good standard to go for

under linux i believe you can pass a UTF-8 filename to fopen() and it'll work fine.

Under windows this doesn't work so you would have to convert the filenames to
wchar_t
or whatever the defines for windows are. TCHAR with the _UNICODE defines i think and then use _wfopen()

But that doesn't seem like too much of a big deal.
That way all existing scripts will still work and can easily be extended.

IanB
14th January 2009, 13:57
Got this email from sourceforge, interesting idea about using the short (8.3) names as a hack around.

A difficulty to consider might be how windows map long filenames that collide in the short namespace. I believe it is chronological, i.e 1st file created is FRED~1.AVS, 2nd file created is FRED~2.AVSMessage body follows:

Hello there

First things first. I'm probably using AviSynth for
something that it isn't intended. But I quite like the
fanciness of it :-)
What I'm doing is, I have an AVS script with embedded
subtitles in it (SSA script after __END__ works like a
charm). The script itself checks its own filename and loads
whatever audio and video is available around it with the
same name and plays them with the subtitles over it.
I have a Perl script which generates such files from a AVS
template and timed text information.

Anyway, I've run into some Unicode issues which were quite
easy to fix (or at least circumvent a bit for the AVS
filename part).

First patch is for AVS files with Unicode filenames.
If one tries to play a file with non-local-CP characters in
the file or any part of the path the AVS script cannot be
opened at all.
I'm aware that its not really feasible to rewrite AviSynth
to use wide characters, so I used windows' short filename
form feature to get the scripts loaded. It tries to keep the
last part of the path (the filename) in the long form if
possible, because that would help my special case when I try
to load video/audio files with the same name during the
scripts execution.
Works fine on XP and should on all OSs which allow Unicode
filenames. It even works under Wine :-)@
-------------------------------------------------------------------------------------------------------------------
@
--- avisynth_base/src/core/main.cpp Mon Jun 9 23:53:20 2008
+++ avisynth/src/core/main.cpp Thu Jan 8 16:32:15 2009
@@ -320,6 +320,24 @@ STDMETHODIMP CAVIFileSynth::Load(LPCOLES
char filename[MAX_PATH];

WideCharToMultiByte(AreFileApisANSI() ? CP_ACP : CP_OEMCP, 0, lpszFileName, -1, filename, sizeof filename, NULL, NULL);
+ if (strchr(filename, '?'))
+ {
+ // if a ? ended up in the converted filename there is a non-representable unicode character in the path
+ // Change to the short file name form (8.3 characters per path element).
+ char filenameshort[MAX_PATH], filenamelong[MAX_PATH];
+ OLECHAR lpszFileNameShort[MAX_PATH];
+ strncpy(filenamelong, filename, sizeof filenamelong);
+ GetShortPathNameW(lpszFileName, lpszFileNameShort, MAX_PATH);
+ WideCharToMultiByte(AreFileApisANSI() ? CP_ACP : CP_OEMCP, 0, lpszFileNameShort, MAX_PATH, filenameshort, sizeof filenameshort, NULL, NULL);
+ // Depending if the found '?' is before or after (or on both sides) of the last path devider
+ // use either LONG-PATH/SHORT-FILE or SHORT-PATH/LONG-FILE or SHORT-PATH/SHORT-FILE
+ char* pfls = max(strrchr(filenamelong, '/'), strrchr(filenamelong, '\\'));
+ char* pfss = max(strrchr(filenameshort, '/'), strrchr(filenameshort, '\\'));
+ if (!pfss || !pfls) memcpy(filename, filenameshort, sizeof filenameshort);
+ else if (strchr(filenamelong, '?') > pfls) memcpy(filename+(pfls-filenamelong), pfss, sizeof(filenamelong)-(pfls-filenamelong));
+ else if (strchr(pfls, '?')) memcpy(filename, filenameshort, sizeof filenameshort);
+ else { memcpy(filename, filenameshort, pfss-filenameshort); memcpy(filename+(pfss-filenameshort), pfls, sizeof(filenameshort)-(pfss-filenameshort)); }
+ }

_RPT3(0,"%p->CAVIFileSynth::Load(\"%s\", 0x%X)\n", this, filename, grfMode);
@
-------------------------------------------------------------------------------------------------------------------
@The second one is for scripts with an added UTF-8 header
thingy often (mis-)called 'byte order mark'. The thing is, I
need these (or rather VSFilter TextSub does) three bytes at
the beginning to get (embedded) Unicode subtitles up and
running. Other than that, it doesn't really hinder the
execution of the script at all, as of course, UTF-8 is fully
compatible with ANSI ASCII.
The setting of the null-terminator was moved up so it will
be there when memmove is being done.@
-------------------------------------------------------------------------------------------------------------------
@
--- avisynth_bases/src/core/parser/script.cpp Fri Jun 20 05:58:18 2008
+++ avisynth/src/core/parser/script.cpp Wed Jan 14 01:13:52 2009
@@ -268,6 +268,7 @@ AVSValue Import(AVSValue args, void*, IS
if (!ReadFile(h, buf, size, &size, NULL))
env->ThrowError("Import: unable to read \"%s\"", script_name);
CloseHandle(h);
+ ((char*)buf)[size] = 0;

// Give Unicode smartarses a hint they need to use ANSI encoding
if (size >= 2) {
@@ -278,11 +279,9 @@ AVSValue Import(AVSValue args, void*, IS
"re-save script with ANSI encoding! : \"%s\"", script_name);

if (q[0]==0xEF && q[1]==0xBB && q[2]==0xBF)
- env->ThrowError("Import: UTF-8 source files are not supported, "
- "re-save script with ANSI encoding! : \"%s\"", script_name);
+ memmove(buf, buf+3, size-3+1);
}

- ((char*)buf)[size] = 0;
AVSValue eval_args[] = { (char*)buf, script_name };
result = env->Invoke("Eval", AVSValue(eval_args, 2));
}
@
-------------------------------------------------------------------------------------------------------------------
@I'm aware that I'm kinda late now with 2.58 out, but maybe
you can use this to get some kind of new alpha or beta out
with an updated copyright notice :-)

Greetings from Tokyo Japan,
Bernhard
--
This message has been sent to you, a registered SourceForge.net user,
by another site user, through the SourceForge.net site. This message
has been delivered to your SourceForge.net mail alias. You may reply
to this message using the "Reply" feature of your email client, or
using the messaging facility of SourceForge.net at:
https://sourceforge.net/sendmessage.php?touser=314083

Barna
20th January 2009, 04:02
Yay after 5 long days I am finally allowed to post :-)

There are no collisions possible in the short form.
It's the operating system which cares for that. For Windows and its two file systems VFAT and NTFS it actually stores the short forms in there. So that means the short forms are generated during the naming of the file and will not change until the (long) name does.
After ~1,~2,~3,~4 the naming (at least under NTFS) changes to some hashing/random type which just keeps the first two ascii letters.

Oh, and I'm not sure how I feel about having my full name and an email address that forwards to my main one being posted on a public forum...

Wilbert
20th January 2009, 18:49
Oh, and I'm not sure how I feel about having my full name and an email address that forwards to my main one being posted on a public forum...
Barna is offline Report Post IP Click Here to Strike Barna
I removed them for you. Sorry about that.

IanB
20th January 2009, 23:38
...
Oh, and I'm not sure how I feel about having my full name and an email address that forwards to my main one being posted on a public forum...Sorry about that, I need to censor more when I cut and paste. Thanks Wilbert.
There are no collisions possible in the short form.
It's the operating system which cares for that. For Windows and its two file systems VFAT and NTFS it actually stores the short forms in there. So that means the short forms are generated during the naming of the file and will not change until the (long) name does.
After ~1,~2,~3,~4 the naming (at least under NTFS) changes to some hashing/random type which just keeps the first two ascii letters.Yes I guess collisions do not matter here, the appropriate script will get opened.

For the benefit of others, I was worried that you cannot predict the short name for a given long filename, i.e. "Microsoft Sucks.avs" and "Microsoft Blows.avs" translate to "MICROS~1.AVS" and "MICROS~2.AVS", which is which depends on the order of creations.


Given there will never be enough developer cycles to do a Unicode conversion and that such a change would not be transparent to the plugin API (i.e. recompile ALL the plugins in existence) I am currently leaning towards making the internals UTF-8.


This means all wide char system entries would do WideCharToMultiByte(CP_UTF8, ...

And all file system interaction would do MultiByteToWideChar(CP_UTF8, ... followed by using the ...W() version of the Windows API.

In Import for BOM-less ASCII files do a MultiByteToWideChar(AreFileApisANSI() ? CP_ACP : CP_OEMCP, ... ->> WideCharToMultiByte(CP_UTF8, ..., for files with a BOM, i.e. UTF, UNICODE, etc strip the BOM and directly translate to UTF8.

To support plugins that deal with the file system provide a ShortPathName() function that uses similar logic to Bernhards above and maybe UTF8_to_ANSI/UTF8_to_OEM/UTF8_to_ASCII() string functions.

Within the 7 bit ASCII character set the change would be transparent.

Only scripts that contain, Code Page specific characters and feeds those characters to plugins that interact with ANSI file API's, will need modification. Currently this case works and fails by the grace of god anyway. Feeding to internal functions will work as expected.

Thoughts?

IanB
20th January 2009, 23:48
Remember, because Avisynth is a library stuffing around with the process/thread codepage settings is not possible, just like we cannot pop messageboxes.

Hence the "MultiByteToWideChar(CP_UTF8, ... followed by using the ...W() version of the Windows API." gymnastics will be needed in place of any ANSI file system API's.

stax76
16th February 2010, 12:59
Apparently the script self cannot have a unicode filename like:

...\Hoří, má panenko.avs

Shows: Import: Couldn't open "...\Hoří, má panenko.avs"

Using version 2.58

IanB
16th February 2010, 21:40
@stax76, yes this is true. As long as we continue to use ...A() windows system calls there will be problems using unicode characters that are not available in the active codepage for the host application.

mariush
17th February 2010, 03:30
No.

The BOM is optional and will most likely appear only if the architecture is different, like little endian vs big endian - that's why there are two BOMs. A file can be BOTH ASCII and UTF8 at the same time, as UTF8 includes the ASCII subset.

The best thing would be to ASSUME file is UTF8 and if you stumble on a errors while parsing it, fall back to ASCII. As errors go, there are some documented edge cases and unallowed character combinations, for example as an error you're not allowed to write the pound sign by itself (£) in UTF8 because its character code (0xA3) is used for something else in UTF8, so you have to map it to two bytes.

There's a library ICU (http://site.icu-project.org/) that's also used by PHP to do normalization between UTF formats and code pages and stuff...

ps... AviSource("something", UTF8=true) is kind of dumb... what's next, you'll have utf16=true? If it comes to this, it would make more sense to have Codepage="UTF8" or something like this.

ps2. DON'T make assumptions that the short file names are there. Some people do registry tweakings to disable the creation of short file names or to disable last access/last modified time updates, for better disk access, less I/O, whatever, so these short file names are not always there. And... if I remember correctly, on some media they don't exist by default - like 8GB micro sd cards or removable drives or some CD/DVD media.

IanB
17th February 2010, 09:46
@mariush, What do you mean "No." (are you answering my post 1374763 or is this out of context)

Avisynth currently supports ANSI encoding in the host applications current code page. i.e. what the ...A() windows API calls support. To avoid bogus support issues it currently detects UTF8, UTF16le and UTF16be BOM codes and reports a helpless error.

mariush
17th February 2010, 17:08
No... in the sense that I don't agree with what was said in the previous few messages (about short file names), which were posts 25 - 29 when I read the thread (I think I left the page open in a tab and replied after a few hours and that's why it's a bit out of context).

My apologies if it was misunderstood.

stax76
27th June 2010, 18:03
Has there been any progress?

krieger2005
27th June 2010, 22:00
Read in the Blog of the CppCMS-Project (http://art-blog.no-ip.info/cppcms/blog) , that the developer has some problems developing on Windows Multilanguage-Filenames. As i understand he solved his Problem. So maybe look at his results or talk to him would help implimenting access of Multilanguage Filenames.

PS: Here the ULR of the exact Blog-Entry: http://art-blog.no-ip.info/cppcms/blog/post/62

stax76
4th July 2010, 19:21
I have a report that a script name with Russian Unicode chars like предприятий.avs works on Russian systems. Can somebody confirm this? If it works can somebody explain me why? On my German system it's not working.

kemuri-_9
4th July 2010, 20:15
I have a report that a script name with Russian Unicode chars like предприятий.avs works on Russian systems. Can somebody confirm this? If it works can somebody explain me why? On my German system it's not working.

IanB answered your questions already:
Avisynth currently supports ANSI encoding in the host applications current code page. i.e. what the ...A() windows API calls support.

so whatever your windows system is using as the native code page is what avisynth can recognize.
like on my japanese codepage (cp932) system i can use scripts that use filenames with japanese characters,
but i can not use scripts that contain filenames with japanese characters on my english codepage (cp1252) system.

stax76
4th July 2010, 20:55
The report I got must be wrong then, maybe I could try to rename source files converting Unicode chars to ANSI chars if there is a representation, not sure if it can be done with the WinAPI or .NET API or if I need a table or something.

Groucho2004
4th July 2010, 22:27
You seem to be confused about something in Kemuri's reply.

You can easily try it yourself even on your German Windows: Change the code page to cyrillic and restart Windows. Avisynth will accept filenames with cyrillic characters.

Just in case you don't know how:
Control Panel -> Regional and Language Options -> Advanced -> Language for non-Unicode programs -->> Change it to Russian.

stax76
4th July 2010, 23:11
ANSII covered Cyrillic chars are not my problem but Unicode Cyrillic chars which I could possibly convert to ANSII, maybe I'm just writing nonsense, I don't know.

Groucho2004
4th July 2010, 23:16
ANSII covered Cyrillic chars are not my problem but Unicode Cyrillic chars which I could possibly convert to ANSII, maybe I'm just writing nonsense, I don't know.

Are talking about file names or the encoding of the script? If you mean the content of the script then yes, you can easily convert UTF-16 or UTF-8 to Ansi (CP-1251).

stax76
4th July 2010, 23:22
Script file names are my problem, StaxRip generates those based on the name of the source file and the source file will of course also appear in the scripts but that's not a problem it seems.

Groucho2004
4th July 2010, 23:27
Script file names are my problem, StaxRip generates those based on the name of the source file and the source file will of course also appear in the scripts but that's not a problem it seems.

So, as far as I understand, the report you got about Russian file names states that there is no problem, right? If that is the case, what exactly is the problem?

stax76
4th July 2010, 23:58
StaxRip rejects Unicode file names, it was requested to remove this but I don't believe it can be removed because it cannot work, it can work with Cyrillic ANSII but not with Cyrillic Unicode. Using alternative script names would be a big task as scripts are generated in countless locations with complicated code. At least I can say it's not my fault.

Groucho2004
5th July 2010, 00:29
StaxRip rejects Unicode file names, it was requested to remove this but I don't believe it can be removed because it cannot work, it can work with Cyrillic ANSII but not with Cyrillic Unicode. Using alternative script names would be a big task as scripts are generated in countless locations with complicated code.

Windows stores file names internally always as Unicode (UTF-16) in order to provide support for file names for all languages. The system code page determines how the characters of the file names are interpreted by the API (if you don't override the default code page in your file and string operations).

I simply don't understand your problem. Since Avisynth doesn't support UTF-8 or UTF-16 you have to create your scripts with the appropriate MBCS encoding using the correct code page. There are Win32 API functions you can use to ensure the proper encoding. Even dummy programming languages like VB should support this.
I'm doing this in plain C without problems, one would think that .NET (which I assume you're using) should make this very simple.

At least I can say it's not my fault.
I suggest you do some reading on the matter and re-think that statement.

HayateYuki
11th July 2010, 10:30
Actually, IMHO, for nowadays programs on Windows platforms, Native Unicode support could be the base requirement.

Such as using only Unicode version of API, which there is "W" at the end of API functions...

It could be huge difficulty, but it could be the only complete way to avoid any this kind of problems...

For AVS script parser, as like foxyshadis said, BOM could be the best way to determine whether the script is UTF-8, UTF-16 or MBCS encoding, then convert them to UTF-16 with MultiByteToWideChar() and then do the things...

Please, throw away ...A() for future version.

stax76
11th July 2010, 14:42
then convert them to UTF-16 with MultiByteToWideChar() and then do the things...

And that is the problem as I understand it, the core is 8 bit instead of 16 and it's not easy to port it to 16 bit.

kemuri-_9
11th July 2010, 15:11
Please, throw away ...A() for future version.

it's not as simple as just tossing the 'A', from the API functions and it'll magically just work.

avisynth is highly designed around the use of char * which would all have to be changed to wchar_t * if unicode was to be used and supported within scripts.
this is by no means a trivial change.
let's not forget that this core change would break every current filter there is as well, and it's no small undertaking to fix them all either.

the avisynth project is even defined to use MBCS which defines 'A'-less API calls back to 'A' versions through the preprocessor.

Midzuki
11th July 2010, 15:40
Just a nit-pick, but, IMHO,

"Foreign Language characters in filenames"

should be replaced by

"Non-ASCII characters in filenames"

(or: "Non-ANSI characters in filenames")

((because "foreign" is just a point-of-view)).