Aspose::Words::Saving::HtmlFixedSaveOptions::set_Encoding method

HtmlFixedSaveOptions::set_Encoding method

Specifies the encoding to use when exporting to HTML. Default value is new UTF8Encoding(true) (UTF-8 with BOM).

void Aspose::Words::Saving::HtmlFixedSaveOptions::set_Encoding(const System::SharedPtr<System::Text::Encoding> & value)

Examples

Shows how to set which encoding to use while exporting a document to HTML.

auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);

builder->Writeln(u"Hello World!");

// The default encoding is UTF-8. If we want to represent our document using a different encoding,
// we can use a SaveOptions object to set a specific encoding.
auto htmlFixedSaveOptions = System::MakeObject<Aspose::Words::Saving::HtmlFixedSaveOptions>();
htmlFixedSaveOptions->set_Encoding(System::Text::Encoding::get_ASCII());

ASSERT_EQ(htmlFixedSaveOptions->get_Encoding()->get_EncodingName(), u"US-ASCII");

doc->Save(get_ArtifactsDir() + u"HtmlFixedSaveOptions.UseEncoding.html", htmlFixedSaveOptions);

See Also