login about faq

I'm trying to check whether a file has been saved with UTF-8 encoding (with/without BOM/preamble) but in my tests .VerifyFile always returns 0.

ActiveX | v9.5.0.60

sFilePathLocal = "e:\temp\test.txt"

with Server.CreateObject("Chilkat_9_5_0.FileAccess")
   .WriteEntireTextFile sFilePathLocal, "abc-£-123", "utf-8", 1
end with

with Server.CreateObject("Chilkat_9_5_0.Charset")
response.write .VerifyFile("utf-8", sFilePathLocal)
end with

asked Feb 08 '17 at 04:32

ianRefractiv's gravatar image

ianRefractiv
262


Doh - I was using .UnlockComponent with the wrong code. Thank you!

link

answered Feb 08 '17 at 08:59

ianRefractiv's gravatar image

ianRefractiv
262

Check the Charset object's LastErrorText property after calling VerifyFile.

Also, examine the contents of the test.txt file using a good editor such as EmEditor (where you can view as binary/hex) or use a hex editor.

The text.txt file should contain this: EF BB BF 61 62 63 2D C2 A3 2D 31 32 33

The "EF BB BF" are the utf-8 BOM bytes. The £ is composed of the bytes C2 A3 in utf-8.

link

answered Feb 08 '17 at 08:12

chilkat's gravatar image

chilkat ♦♦
12.8k318380528

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×12

Asked: Feb 08 '17 at 04:32

Seen: 483 times

Last updated: Feb 08 '17 at 08:59

powered by OSQA