Child pages
  • UAPI Functions - Fileman::transcode

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

 

Description

Excerpt

This function converts a buffer from one encoding language to another.

Multiexcerpt include
SpaceWithExcerptcom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@12665
MultiExcerptNameAPIDisabledFileStorageRole
PageWithExcerptLIB:_ServerRoleDisabledAPI

Panel
bgColor#F2F2F2
borderStylenone

Examples 


Panel
bgColor#FFFFFF
borderStylenone


Expand
titlecPanel or Webmail Session URL


Code Block
https://hostname.example.com:2083/cpsess##########/execute/Fileman/transcode?from_charset=utf-8&to_charset=us-ascii&content="hi"&discard_illegal=1&transliterate=1

 

Include Page
LIB:_CallUAPIFromBrowserLink
LIB:_CallUAPIFromBrowserLink


Expand
titleLiveAPI PHP Class


Code Block
languagephp
linenumberstrue
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Convert file from UTF-8 to ASCII.
$convert_file_encoding = $cpanel->uapi(
    'Fileman', 'transcode',
		array(
		'from_charset'		=> 'UTF-8',
		'to_charset'		=> 'ASCII',
		'content'			=> '"hi"',
		'discard_illegal'	=> '0',
		'transliterate'		=> '0',
  )
);

Include Page
LIB:_LiveAPIPHPLink
LIB:_LiveAPIPHPLink

 


Expand
titleLiveAPI Perl Module


Code Block
languageperl
linenumberstrue
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Convert file from UTF-8 to ASCII.
my $ convert_file_encoding = $cpliveapi->uapi(
 'Fileman', 'transcode',
		{
		'from_charset'		=> 'UTF-8',
		'to_charset'		=> 'ASCII',
		'content'			=> '"hi"',
		'discard_illegal'	=> '0',
		'transliterate'		=> '0',
		}
 );

Include Page
LIB:_LiveAPIPerlLink
LIB:_LiveAPIPerlLink

 


Expand
titlecPanel Template Toolkit


Code Block
languagexml
linenumberstrue
<!-- Get a hash of all the data, then display the charset value. -->
[% data = execute( 'Fileman', 'upload_files' {'from_charset' => 'UTF-8', 'to_charset' => 'ASCII', 'content' => '"hi", 'discard_illegal' => '1', 'translitertate' => '0',} ); %]
[% FOREACH q = data.path %]
     <p>
         [% q %]
     </p>
[% END %]
 
<!-- Get only a hash of the data. -->
[% execute('Fileman', 'upload_files' {'from_charset' => 'UTF-8', 'to_charset' => 'ASCII', 'content' => '"hi", 'discard_illegal' => '1', 'translitertate' => '0',}  ).data.path %]

Include Page
LIB:_TTLink
LIB:_TTLink

 


Expand
titleCommand Line


Code Block
languagebash
uapi --user=username Fileman transcode from_charset=utf-8 to_charset=us-ascii content=\"hi\" discard_illegal=1 transliterate=1

Include Page
LIB:_UAPICLINote
LIB:_UAPICLINote


Expand
titleOutput (JSON)


Code Block
languagetext
linenumberstrue
{  
   "messages":null,
   "errors":null,
   "status":1,
   "metadata":{  

  },
  "data": {
    "from_charset": "utf-8",
    "to_charset": "utf-8",
    "path": "/home/username/public_html/example.html"
  }
}


Include Page
LIB:_cPanelAPIShellNote
LIB:_cPanelAPIShellNote

   


Parameters

ParametersTypeDescriptionPossible valuesExample
contentstring

Required

The file's contents.

A string value."hi"
from_charsetstring

The file's current character set encoding.

 

Any cPanel-supported character set encoding.

UTF-8

 
to_charsetstring

The character set encoding in which to encode the file.

Any cPanel-supported character set encoding.

ASCII

 
discard_illegalBooleanWhether to discard any characters that do not transcode correctly.1
transliterateBooleanWhether to transcode invaid characters to valid characters in the new character set encoding.0

Returns

ReturnTypeDescriptionPossible valuesExample
contentstringThe file content.A string value."hi"
charsetstring

The file's new character set.

A cPanel-supported character set encoding.

ASCII