Advertisement

03.07.2008 at 06:51PM PST, ID: 23224646 | Points: 500
[x]
Attachment Details

Sed and UTF-16

Tags: Apple
I have an Apple file, InfoPlist.strings, that is in UTF-16 format. I am using an sed string, that I was helped with here on this forum, for searching the file to replace a version number as:

number="0.9.8.7"
sed "s/\(#define VERSION.*\"\)\0-9]\.[0-9]\.[0-9]\.[0-9]/\1V$number\"/" file >/tmp/$$
mv /tmp/$$ /mydir/file

this works great on non UTF-16 files but now I need to use it on the UTF-16 file. I read about sed supporting \xHH as an escape sequence for hex notation but I am not sure how to use this in my script.

Looking for some help on how I can manipulate text in my UTF-16 file.

Quick note I am searching for the string #define VERSION     "1.2.3.4" and replacing the 1.2.3.4 with what every number the user/script types in as an argument.

Thanks
Carl
Start your free trial to view this solution
Question Stats
Zone: Apple
Question Asked By: atomicgs12
Question Asked On: 03.07.2008
Participating Experts: 1
Points: 500
Views: 0
Translate:
Loading Advertisement...
03.09.2008 at 03:36AM PDT, ID: 21080858

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.10.2008 at 10:51AM PDT, ID: 21088566

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.10.2008 at 12:20PM PDT, ID: 21089408

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.10.2008 at 12:25PM PDT, ID: 21089454

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.10.2008 at 12:47PM PDT, ID: 21089725

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.10.2008 at 12:54PM PDT, ID: 21089794

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
03.09.2008 at 03:36AM PDT, ID: 21080858

Rank: Wizard

> .. I have an Apple file, InfoPlist.strings ..
so you're on a Mac?
then I'd use defaults command and pipe the output through sed
According your posted sed command line: if it does what you want depends on the shell you issue that command 'cause you use escaped " , I'd use it as follows:

sed -e 's/\(#define VERSION.*"\)[0-9]\.[0-9]\.[0-9]\.[0-9]/\1'$number'"/' file >/tmp/$$

Also keep in mind that sed is not UTF compliant, though I'm not sure how BSD's sed on Mac behaves ..
 
03.10.2008 at 10:51AM PDT, ID: 21088566
Yes this is running on a MAC and shell is 'bash'. If sed is not UTF compliant then I need a way to find, in the UTF the version number that I am looking for and replace it with the number I pass in as an arg parameter. SED will NOT find the version number in the UTF file as it does in the other none UTF files. I thought there was some setting that would force sed to use or become UTF compliant. IF there is not a way then I need a solution for a UTF file.
Thanks
 
03.10.2008 at 12:20PM PDT, ID: 21089408

Rank: Wizard

even OS X is Unix-based, Mac's unix support is a pain, sometimes, somehow ...
You may try awk instead, but I gues that it's as old fashoined as sed ..
Then your friend will be perl.
Can you please check if the file contains a BOM, use od -x for that.
 
03.10.2008 at 12:25PM PDT, ID: 21089454
Ahoffmann -
What is a 'BOM'? I used od -x what am I looking for?
Thanks
 
03.10.2008 at 12:47PM PDT, ID: 21089725

Rank: Wizard

od -x your file |head

will show the content of your file in hex notation
The BOM -byte order mark- is a special 2- or 3-byte code used in UTF files. For UTF16 it must be FEFF or FFFE as the very first 2 bytes in the file. The above od command should prove this.
 
03.10.2008 at 12:54PM PDT, ID: 21089794
Thanks Ahoffmann:
I am getting like: feff 002f 002a 0020 004c 006f ....
All the characters have the 00 in front of them except for the first feff.
Thanks for the explanation of the BOM notation.
I remember reading on the web about using \x00 in front of the character(s) that one is trying to search for in the SED call but again I don't see how to incorporate that with what I am trying to do.

Cheers
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628