←Select platform

HasBom Property

Summary
Determines whether the file contains a byte-order mark (BOM) to indicate the text encoding.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public bool HasBom { get; } 
@property (nonatomic, assign, readonly) BOOL hasBom; 
public boolean HasBom() 
public: 
property bool HasBom { 
   bool get(); 
} 
HasBom # get  (CodecsImageInfo) 

Property Value

true if the file contains a BOM; false, otherwise. The default value is false.

If this property is false and the source file contains text, the file will be assumed to have an encoding indicated by CodecsTxtLoadOptions.DefaultEncoding.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
 
using Leadtools.ImageProcessing.Core; 
using Leadtools.Pdf; 
 
// This C# example shows you how to load a file called "Ansi.txt" that contains ANSI text.  
public void CodecsTxtLoadOptionsDefaultEncoding_Example() 
{ 
   using (RasterCodecs codecs = new RasterCodecs()) 
   { 
      string srcFile = @"Ansi.txt"; 
      using (CodecsImageInfo info = codecs.GetInformation(srcFile, false)) 
      { 
         if (!info.HasBom) 
            codecs.Options.Txt.Load.DefaultEncoding = CodecsTxtEncoding.Ansi; /* Load as Ansi. Here you can bring up a message box asking the user to select the encoding */ 
         codecs.Options.Load.AllPages = true; 
         using (RasterImage image = codecs.Load(srcFile)) 
         { 
            codecs.Save(image, srcFile + ".tif", RasterImageFormat.TifLzw, 0); 
         } 
      } 
   } 
} 
 
import java.io.File; 
import java.io.IOException; 
import java.net.URI; 
import java.net.URISyntaxException; 
import java.nio.file.Paths; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.imageprocessing.core.MinMaxBitsCommand; 
 
 
// This C# example shows you how to load a file called "Ansi.txt" that contains 
// ANSI text. 
public void codecsTxtLoadOptionsDefaultEncodingExample() { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   RasterCodecs codecs = new RasterCodecs(); 
   String srcFile = combine(LEAD_VARS_IMAGES_DIR, "Example.txt"); 
   CodecsImageInfo info = codecs.getInformation(srcFile, false); 
   if (!info.hasBom()) 
      codecs.getOptions().getTxt().getLoad().setDefaultEncoding(CodecsTxtEncoding.ANSI); // Load as Ansi. Here you 
                                                                                         // can bring up a message 
                                                                                         // box asking the user to 
                                                                                         // select the encoding // 
 
   codecs.getOptions().getLoad().setAllPages(true); 
   RasterImage image = codecs.load(srcFile); 
 
   codecs.save(image, srcFile + ".tif", RasterImageFormat.TIFLZW, 0); 
 
   assertTrue("File unsuccessfully saved to " + srcFile + ".tif", (new File(srcFile + ".tif")).exists()); 
   System.out.printf("File successfully saved to %s%n", srcFile + ".tif"); 
 
   image = null; 
   info = null; 
   codecs = null; 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Codecs Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.