UAPI Functions - Fileman::transcode

Description

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

Examples 


 cPanel or Webmail Session URL

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

 LiveAPI PHP Class

$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',
  )
);

 LiveAPI Perl Module

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',
        }
 );

 cPanel Template Toolkit

<!-- 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 %]

 Command Line

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

 

Notes:

  • You must URI-encode values.
  • username represents your account-level username.

 Output (JSON)

   "messages":null,
   "errors":null,
   "status":1,
   "metadata":{ 
 
  },
  "data": {
    "from_charset": "utf-8",
    "to_charset": "utf-8",
    "path": "/home/username/public_html/example.html"
  }
}

 

Note:

Use cPanel's API Shell interface (Home >> Advanced >> API Shell) to directly test cPanel API calls.

 

Parameters

Parameters

Type

Description

Possible values

 Example 

content

string

Required

The file's contents.

A string value.

"hi"

from_charset

string

The file's current character set encoding.

 

Any cPanel-supported character set encoding.

UTF-8

 

to_charset

string

The character set encoding in which to encode the file.

Any cPanel-supported character set encoding.

ASCII

 

 discard_illegal 

Boolean

Whether to discard any characters that do not transcode correctly.

  • 1 — Discard invalid characters.
  • 0 — Transcode invalid characters in the default character set encoding. 

 

1

transliterate

 Boolean 

 Whether to transcode invaid characters to valid characters in the new character set encoding. 

  • 1 — Transcode invalid characters in the new character set encoding.
  • 0 — Return an error message.

0

 

Returns

 Return 

Type

Description

Possible values

 Example 

content

string

The file content.

A string value.

"hi"

 charset

 string 

 The file's new character set. 

 A cPanel-supported character set encoding. 

   ASCII

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

The cPanel Interface

For  cPanel  &  WHM  version  58 Overview The cPanel interface is...

User Preferences

For cPanel & WHM version 58 Overview This document outlines how to access your cPanel...

Manage External Authentications

For cPanel & WHM version 58 Overview Manage credentials Additional documentation...

What is cPanelID?

In This Article:  Overview ServicesHow to get a cPanelID cPanelID External...

Guide to cPanel Interface Customization - cPanel Style Development

Introduction You can develop custom styles that modify the appearance of the cPanel interface....