Convert integer to string preserving order The quest is to convert an integer to a string in such a way that 1. the order is preserved 2. using the least number of characters in the string. 

Let's say I have an integer X; the objective is to create a function f (and respective inverse, g, such that:

Conditions


f(X) is a utf-8 string for all integer X
g(f(X)) = X
Ordering is preserved. That is, if I have another integer Y, X > Y implies f(X) > f(Y) 
The integer means it can be negative
Assume integers in [-2^63, 2^63 - 1]


Winning criterion


The answer must fulfill the conditions above
Make f(X) represent the number in the least number of UTF-8 characters. 
Of answers complying with 1 and 2, smallest code wins (sum of code of f and code of g)


Example

(Python)

def f(x):
    return '%019d' % x  # log10(2^63 - 1) ~ 18.9

def g(x):
    return int(x)


Notice that it is not clear that f is optimal since it always uses the same number of characters (independent of x).

This is my first challenge here and I'm not sure if this fits this Q&amp;A, but it seemed to me a nice and useful problem. I'm also trying to solve it.
PowerShell, 185

$s=32767
function f($x){$a='';while($x){$r=$x%$s;$a+=[char]($r+$s)
[long]$x=[bigint]::divide($x,$s)};$a}
function g($x){$a=0;0..($x.length-1)|%{$a+=($x[$_]-$s)*[bigint]::pow($s,$_)};$a}


Ungolfed

$shift = 32767

function f($number) {
    $string = ''
    while($number) {
        $remain = $number % $shift
        $string += [char]($remain+$shift)
        [long]$number = [bigint]::divide($number, $shift)
    }
    $string
}

function g($string) {
    [long]$number = 0
    0..($string.length-1)|%{$number += ($string[$_]-$shift)*[bigint]::pow($shift, $_)}
    $number
}


At most, the output will be length 5.

&gt; f ([long]::MaxValue)
耆耟耯耟耇
&gt; g '耆耟耯耟耇'
9223372036854775807
&gt; f ([long]::MinValue)
翷翟翏翟翷
&gt; g '翷翟翏翟翷'
-9223372036854775808