With the string fully composed, WriteLine will write the following to the XML file: All we’re doing is calling the WriteLine method, and asking WriteLine to do the following.įirst, we need it to compose the string to be written, starting with the characters ”. Yes, it looks weird, but it’s really not that bad.
#How can i find what my text encoding is code
That brings us to the line of code that writes the desired line to the file: objFile.WriteLine “” We begin by creating an instance of the FileSystemObject and then calling the CreateTextFile method to create the file C:\Scripts\Test.xml. Set objFile = objFSO.CreateTextFile(“C:\Scripts\test.xml”) Here’s a script that writes the desired line to the file C:\Scripts\Test.xml: Set objFSO = CreateObject(“Scripting.FileSystemObject”) Trust us it’s much easier than it sounds. If we want to insert double quotes into a file we can do this by specifying Chr(34) the Chr function takes the ASCII value – 34 – and converts it to an actual character (in this case double quotes). As you probably know, all the characters you can type on the keyboard are represented by an ASCII value for example, double quotes have an ASCII value of 34. There are a couple different ways to do this, but we’re going to focus on just one (although we’ll briefly show you the other at the end of this column): we’re going to use VBScript’s Chr function to represent double quotes. To get around this we need to find a different way to specify that double quotes should be written to the text file. As a result, it simply throws up its hands in despair, and the script fails. That’s not a valid scripting command, and VBScript has no idea what that means. As far as our script is concerned, your string actually consists of this: “”. Why? Well, like we said, double quotes indicate the beginning and ending of strings.
![how can i find what my text encoding is how can i find what my text encoding is](https://upload.wikimedia.org/wikipedia/commons/thumb/0/09/New_Unicode_logo.svg/1200px-New_Unicode_logo.svg.png)
A line of code like this is bound to end in failure: objFile.WriteLine “” Double quotes can be a major nuisance when trying to write data to text files (and an XML file, of course, is just a text file) that’s because double quotes are used to, among other things, indicate where strings begin and end. However, you’re getting hung up on the double quotes that surround 1.0 and UTF-8. According to your email, you’re trying to write the following line to your XML file:
![how can i find what my text encoding is how can i find what my text encoding is](https://smsbump.com/img/uploads/smsbump-smart-encoding-disabled-shopify_bb49d0ada4.png)
However, I need to put double quote marks around some of the items in that file. Hey, Scripting Guy! I’m using the FileSystemObject to create an XML file.