You are here

NewTextReplace Beta 4.1, ANSI & Unicode NSIS

14 posts / 0 new
Last post
Mark Sikkema
Offline
Last seen: 10 years 10 months ago
Developer
Joined: 2009-07-20 14:55
NewTextReplace Beta 4.1, ANSI & Unicode NSIS

This is developed especially for files with odd binary data, such ass media libraries and any Unicoded files.

I have modified textreplace.dll, to deal with ALL unicode files.
NewTextReplace Plugin for Ansi- & Unicode NSIS

Release Notes:

Development Test 4.1 (2010-01-19)

  • notes:
    Added additional credit to the dev. of the TextReplace plug-in.
    It did already for the source and readme, but not for the .nsh file.
    As it ends up being the only file included into most packages, I considered it important enough to update.

Development Test 4 (2010-02-04)

  • features:
    All the code is in C, so no more extended macros.
    Fully compatible with ReplaceInFileWithTextReplace.nsh
  • bug fix:
    The last release had a messagebox appearing, left behind of my testing. Has been dealed with!
  • known bugs:
    Case-Insensitive, only works if using latin characters !

Development Test 3 (2010-01-19)

  • notes:
    Full support for ANSI- & Unicode NSIS

Development Test 2.1 (2010-01-14)

  • notes:
    The plugin has not been updated, just done some changes to the macros !!!
  • bug fix:
    Fixed the warnings, when compiling for UTF-8
    Done away with the unicode Messagebox function

Development Test 2 (2010-01-14)

  • features:
    UTF-16LE support added
    MultiByteToWideChar() function added, which converts UTF-8 to UTF-16LE on a proper way.
    Messagebox function which shows UTF-8 strings

Development Test 1 (2010-01-11): Initial release

  • features:
    UTF-8 support

Mark Sikkema
Offline
Last seen: 10 years 10 months ago
Developer
Joined: 2009-07-20 14:55
My self I tested this

fully in Cyrillic script.
The file paths as well as the artist names and song names all stayed in tact !

Formerly Gringoloco
Windows XP Pro sp3 x32

Mark Sikkema
Offline
Last seen: 10 years 10 months ago
Developer
Joined: 2009-07-20 14:55
Updated.

The UTF16LE part will be used in the next DT of Winamp Portable, which will be released these days.

Of course the wide chars are just ansi chars with '00' added.

Anyway, as I've spend some time at learning a bit of C, I've also developed a modified version of textreplace.dll . It just needed to be slightly modified, so it doesn't fail when ever it encounters an '00' byte. Just trying to make it do UTF16LE seems to be much harder, due to the terminating '00' problem in the search and replacement string.

First I have to finish the new update of Winamp Portable 557 (finally), then I will have a look at it again and included it here.

Formerly Gringoloco
Windows XP Pro sp3 x32

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 7 years 1 month ago
Joined: 2007-04-15 21:08
Great!

I'm glad that you're handling it in TextReplace itself. It would definitely help a lot if there was a Unicode version of TextReplace for NSISu.

That's really far and away the best solution.

I am a Christian and a developer and moderator here.

“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1

Mark Sikkema
Offline
Last seen: 10 years 10 months ago
Developer
Joined: 2009-07-20 14:55
Included 'NewTextReplace.dll'

in the main topic, above ! Including the source of course.

It was quite a simple modification, so I don't see it having (m)any bugs!
The main thing I modified was, adding 'nReadBufSize' as an extra argument to function 'StrReplace()' in 'StrFunc.h' and make it loop till the end of the file, instead of a loop till the fist '00' byte !
Probably the following line could be deleted as well, but it does the job as it is!

        if (!*pText) goto End;

Oh, as well I dissabled the check for binary data in function 'FillReadBuffer()' in 'textreplace.c'.

About the UTF-16 function for textreplace, first I want to (try to) develop it for the ansi version of NSIS.
Once I get the UTF-16 working, I probably will start a new tread for this(or start this one all over).
Anyway, that probably be a while, as I probably have to write a whole new code for UTF-16 files. The main problem is that any '00' byte in the search string will be seen as the end of the string. Aswell I had a problem with char & wchar_t, they do not seem to like to be used within the same script.
But I just have learn a lot more by finding more info on internet and trail & error of course.

About NSIS or NSISu, I would like a discussion about this, cause I'm not sure PA.c does need NSISu at all.
The way NSIS is right now, it basically can handle UTF-8 anyhow !!! The only thing I can't get it to do is show a 'MessageBox' with proper UTF-8 characters(which shouldn't be to hard to solve). But it reads UTF-8 strings out of any .ini or .txt files, write them again, and do replaceinfile. The NSIS variables do not mind this format !!!
I believe thats why UTF-8 got developed in the first place, probably it has a lot more potential then the other unicode formats.

Another issue for ansi NSIS is the registry plugin, it doesn't handle any unicode values. Even ${registry::CopyKey} messes up the key if it contains Unicode values. I consider this a big problem, it has the potential to leave values messed up on the users machine.
And as you know ${registry::SaveKey}doesn't save unicode values(a main issue in both versions).

Anyway, I'll be working on it next weekend !

Formerly Gringoloco
Windows XP Pro sp3 x32

Mark Sikkema
Offline
Last seen: 10 years 10 months ago
Developer
Joined: 2009-07-20 14:55
Finally, I got it done !

Finally, I got it done !

Formerly Gringoloco
Windows XP Pro sp3 x32

prapper
Offline
Last seen: 1 year 6 months ago
Developer
Joined: 2008-01-24 17:01
uTorrent

I was just about to post, I've been using ReplaceInFileWithUnicode.nsh beta 4 in uTorrent for the last couple of days and it's working great. As you said in another post, uTorrent creates the .bad files and the message "Warning: file integrity check failed (hash doesn't match)" appears in the logger for resume.dat & settings.dat but all preferences are saved and torrents are loaded across different drives.

I'll update to this one today. Thanks Smile I'll do XMPlay & Mp3tag too (no complaints so far).

EDIT: I'm losing track of the versions though... is this topic always going to be the latest?

Mark Sikkema
Offline
Last seen: 10 years 10 months ago
Developer
Joined: 2009-07-20 14:55
This is a totally new aproach

This is a totally new aproach !

Based on the origanal textreplace plugin, coded in C!

Thats why there is a new version number.

Cause it is in C, it will be much faster.

[edit: I think this topic is all ways going to be the latest (if it wouldn't, I would put a note on the topic(]

Formerly Gringoloco
Windows XP Pro sp3 x32

prapper
Offline
Last seen: 1 year 6 months ago
Developer
Joined: 2008-01-24 17:01
With uTorrent

OK, struggling a bit with this one, but here goes -

;(Custom)
!addplugindir plugins
!include NewTextReplace.nsh
!include UTF16.nsh

etc...

${ReplaceInFileCS} '$SETTINGSDIRECTORY\resume.dat' '$LASTDRIVE\' '$CURRENTDRIVE\'
${ReplaceInFileCS} '$SETTINGSDIRECTORY\settings.dat' '$LASTDRIVE\' '$CURRENTDRIVE\'
;=== ${ReplaceInFileUTF16LECS} '$SETTINGSDIRECTORY\resume.dat' '$LASTDRIVE\' '$CURRENTDRIVE\'
;=== ${ReplaceInFileUTF16LECS} '$SETTINGSDIRECTORY\settings.dat' '$LASTDRIVE\' '$CURRENTDRIVE\'

etc...

${textreplace::Unload}
;=== ${System::Unload}

This is the result -

${ReplaceInFileUTF16LECS} - Compiles without warnings but doesn't replace the drive letters.

${ReplaceInFileCS} - This replaces the drive letters, but compiles with the following warnings -

3 warnings:
  install function "UTF8toUTF16" not referenced - zeroing code (31-104) out

  Variable "_SEARCH_TEXT" not referenced or never set, wasting memory!
  Variable "_REPLACEMENT" not referenced or never set, wasting memory!

If I unload the system plugin I get another warning -

unknown variable/constant "_PORTABLEAPPNAME" detected, ignoring (macro:System::Unload:1)

I hope that's of some help! Still getting the hash check failures in the logger when the drive letter changes (but I'm presuming this is unavoidable).

Mark Sikkema
Offline
Last seen: 10 years 10 months ago
Developer
Joined: 2009-07-20 14:55
Sorry,I should include a bit more info !

for uTorrent files you use ${ReplaceInFile} for case insensitive or ${ReplaceInFileCS} for case sensative, cause it is just an ansi/utf-8 file.

About the warnings, sorry I must have missed them in my testing, and I will do away with them next release. But they aren't an issue.
The function to convert utf-8 to utf-16 is not used, cause your updating utf-8 there is no need for converting. Same reason for the need of the variables.

Don't worry about them.

Unloading isn't necessary, for textreplace it is done in the function, just like ReplaceInFileWithTextReplace.nsh.

For ${System::Unload}, I should really come up with a better name for this instruction.
You DO NOT need it ReplaceInFile unloads it self at the end of replacing
${System::Unload} is only used for ${MessageBoxU), to unload the _PORTABLEAPPNAME.
$_PORTABLEAPPNAME is a pointer to the messagebox main title. If you do not use ${MessageBoxU) there is no need to unload !

Can't wait to see them included.
If you need more help, do not hesitate to comment on this topic !

[edit: fixed some spelling mistakes]

Formerly Gringoloco
Windows XP Pro sp3 x32

prapper
Offline
Last seen: 1 year 6 months ago
Developer
Joined: 2008-01-24 17:01
OK, thanks for the info.

OK, thanks for the info. uTorrent isn't my project, obviously, but I see you included the XMPlay library file in your examples so I'll have a look at that one later on. Thanks!

Mark Sikkema
Offline
Last seen: 10 years 10 months ago
Developer
Joined: 2009-07-20 14:55
Minor, but important update

Minor, but important update !
See release notes....

Formerly Gringoloco
Windows XP Pro sp3 x32

habenyamin
Offline
Last seen: 5 months 3 weeks ago
Joined: 2009-02-06 13:04
help

Hi
When I use plugin (nsis Unicode)
it could change All text at utf8 format but couldn't change text at Unicode format

Mark Sikkema
Offline
Last seen: 10 years 10 months ago
Developer
Joined: 2009-07-20 14:55
More info...

I need some more info to be able to tell you what's wrong.
Probably, provide a code-snippet and the files you want to replace in, so I could have a better understanding of your issue and maybe reproduce the problem.

Although the plug-in has been proven to work for PA.c, I know there is a few small bugs in some functions(which the PA.c launchers are not using).

So, I done a re-write of the plug-in a while ago, but didn't want to advertise it here as long as there weren't any complains. (the famous: Don't fix it if it isn't broken Smile )

So you could give NewTextreplace_v0.5.zip a go !

Formerly Gringoloco
Windows XP Pro sp3 x32

Log in or register to post comments