# Unicode text replace

**URL:** https://www.finalbuilder.com/forums/t/unicode-text-replace/611
**Category:** Discussion
**Created:** [October 10, 2007, 12:37pm UTC](https://www.finalbuilder.com/forums/t/unicode-text-replace/611 "2007-10-10T12:37:07Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [October 10, 2007, 12:37pm UTC](https://www.finalbuilder.com/forums/t/unicode-text-replace/611/1 "2007-10-10T12:37:07Z")

</div>

I need to do a text replace action to set a version in a file. This has ben working fine in th epast, but the file has now been changed to be Unicode format. When I do the text replace now it corrupts the file. Is there a way to do a text replacement in a unicode file?

Thanks,

&nbsp;&nbsp;&nbsp;&nbsp; Keith

---

<div class="post-metadata">

### Author: ![angus](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@angus](https://www.finalbuilder.com/forums/u/angus)
#### Post date: [October 10, 2007, 1:18am UTC](https://www.finalbuilder.com/forums/t/unicode-text-replace/611/2 "2007-10-10T01:18:26Z")

</div>

Hi Keith,   
  
 What Unicode format is the file in? UTF-8?   
  
 Regards,   
  
 Angus

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [October 10, 2007, 1:34am UTC](https://www.finalbuilder.com/forums/t/unicode-text-replace/611/3 "2007-10-10T01:34:14Z")

</div>

_sigh_ I’m not 100% sure. The developer says he saved it from Notepad as “Unicode”. I just tried saving it from Notepad and it gives me the choices of:   
 ANSI   
 Unicode   
 Unicode big endian   
 UTF-8   
  
 So I’m not exactly sure what format notepad saves a file in when one specifies “Unicode”. Any clue how to tell what it really is?   
  
 I’m checking with the developer to figure out why we’re using this format.   
  
 _sigh_   
  
 Keith

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [October 10, 2007, 1:48am UTC](https://www.finalbuilder.com/forums/t/unicode-text-replace/611/4 "2007-10-10T01:48:58Z")

</div>

My developer is clueless as to what format it’s in. he just knows that Visual Studio wants it this way. _sigh_ Ever want to go apply a cluestick to someone’s head?   
  
 I’m guessing that since it differentiates “Unicode” from “UTF-8”, and gives and option for “big endian”, that it means UTF-16 when it says Unicode. Microsoft’s web page about the formats in Notepad ([http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/win\_notepad\_utf\_description.mspx?mfr=true](http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/win_notepad_utf_description.mspx?mfr=true)) doesn’t help much, either. I guess they were afraid that having UTF-8 on the page is scary enough and they don’t dare put another scary acronym like UTF-16 on the same page, even though it would be really nice to know if that’s really the standard they’re using.   
  
 Ok, the Wikipedia page ([http://en.wikipedia.org/wiki/Notepad](http://en.wikipedia.org/wiki/Notepad)) for Notepad says it does UTF-16 and UTF-8 and mentions it does both Endians of UTF-16, so this is pretty sure to be UTF-16.   
  
 Keith

---

<div class="post-metadata">

### Author: ![angus](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@angus](https://www.finalbuilder.com/forums/u/angus)
#### Post date: [October 10, 2007, 2:34am UTC](https://www.finalbuilder.com/forums/t/unicode-text-replace/611/5 "2007-10-10T02:34:34Z")

</div>

Thanks Keith. Visual Studio will accept UTF-8 as well, re-saving the file as UTF-8 may solve your problem, if that’s an option for you.   
  
 I’ll take a look and see what else we can do about this.   
  
 Regards,   
  
 Angus

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [February 19, 2009, 2:21am UTC](https://www.finalbuilder.com/forums/t/unicode-text-replace/611/6 "2009-02-19T02:21:12Z")

</div>

When I try and replace text in a file in Unicode Little Endian encoding (first 2 bytes = “\xFF\xFE”) format the file gets corrupted.   
  
 Regards,   
 Andrew

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [February 20, 2009, 12:29pm UTC](https://www.finalbuilder.com/forums/t/unicode-text-replace/611/7 "2009-02-20T12:29:16Z")

</div>

Hi Andrew   
  
Finalbuilder is not really unicode aware at this time.. I'm pretty sure the text replace action just treats the file as ascii. Unicode support is one of the focuses for the next major version of FinalBuilder.

You will probably need to resort to script (using the Run Script) action.

&nbsp;

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [August 17, 2009, 10:16am UTC](https://www.finalbuilder.com/forums/t/unicode-text-replace/611/8 "2009-08-17T10:16:45Z")

</div>

I ran into this Unicode limitation trying to write an Automise 3.0 script to analyze NTBackup log files, which are written in Unicode. I was able to work around it by adapting a VBScript from MSDN and creating a temp file for the analysis.

Before running the VBScript below, set the following variables:

LogFilePathAndName\_Original - the original file (in Unicode)  
LogFilePathAndName - the temp file (used in the remainder of the Automise script)

Mark

' Adapted from "Copy a Unicode File to an ANSI File" under  
' Windows Installer Scripting Examples.  
' http://msdn.microsoft.com/en-us/library/aa368046(VS.85).aspx  
  
Const ForReading = 1  
Const FailIfNotExist = 0  
Const OpenAsDefault = -2  
Const OverwriteIfExist = -1  
Const OpenAsASCII = 0  
  
Set FileSys = CreateObject("Scripting.FileSystemObject")  
Set inStream&nbsp; = FileSys.OpenTextFile(LogFilePathAndName\_Original, ForReading, FailIfNotExist, OpenAsDefault)  
Set outStream = FileSys.CreateTextFile(LogFilePathAndName, OverwriteIfExist, OpenAsASCII)  
Do  
&nbsp;&nbsp;&nbsp; inLine = inStream.ReadLine  
&nbsp;&nbsp;&nbsp; outStream.WriteLine inLine  
Loop Until inStream.AtEndOfStream  
inStream.Close  
outStream.Close
