;
    PyObject *decimal;
    Py_ssize_t decimal_length, new_length;
    int res;

    if (!PyArg_ParseTuple(args, "u#|s", &unicode, &length, &errors))
        return NULL;

    decimal_length = length * 7; /* len('&#8364;') */
    decimal = PyBytes_FromStringAndSize(NULL, decimal_length);
    if (decimal == NULL)
        return NULL;

    res = PyUnicode_EncodeDecimal(unicode, length,
                                  PyBytes_AS_STRING(decimal),
                                  errors);
    if (res < 0) {
        Py_DECREF(decimal);
        return NULL;
    }

    new_length = strlen(PyBytes_AS_STRING(decimal));
    assert(new_length <= decimal_length);
    res = _PyBytes_Resize(&decimal, new_length);
    if (res < 0)
        return NULL;

    return decimal;
}

static PyObject *
unicode_transformdecimaltoascii(PyObject *self, PyObject *args)
{
    Py_UNICODE *unicode;
    Py_ssize_t length;
    if (!PyArg_ParseTuple(args, "u#|s", &unicode, &length))
        return NULL;
    return PyUnicode_TransformDecimalToASCII(unicode, length);
}

static PyObject *
unicode_legacy_string(PyObject *self, PyObject *args)
{
    Py_UNICODE *data;
    Py_ssize_t len;
    PyObject *u;

    if (!PyArg_ParseTuple(args, "u#", &data, &len))
        return NULL;

    u = PyUnicode_FromUnicode(NULL, len);
    if (u == NULL)
        return NULL;

    memcpy(PyUnicode_AS_UNICODE(u), data, len * sizeof(Py_UNICODE));

    if (len > 0) { /* The empty string is always ready. */
        assert(!PyUnicode_IS_READY(u));
    }


; 
     PyObject * decimal; 
     Py_ssize_t decimal_length, new_length; 
     int res; 

     if (! PyArg_ParseTuple(args, " u#|s ", & unicode, & length, & errors) ) 
         return NULL; 

     decimal_length = length * 7; / * len('&#8364;') * / 
     decimal = PyBytes_FromStringAndSize(NULL, decimal_length); 
     if (decimal = = NULL) 
         recurrence NULL; 

     res = PyUnicode_EncodeDecimal(unicode, duration, 
                                   PyBytes_AS_STRING(decimal), 
                                   errors); 
     if (res < 0) { 
         Py_DECREF(decimal); 
         return NULL; 
     } 

     new_length = strlen(PyBytes_AS_STRING(decimal) ); 
     assert(new_length < = decimal_length); 
     res = _ PyBytes_Resize(&decimal, new_length); 
     if (res < 0) 
         return NULL; 

     revert decimal; 
 } 

 static PyObject * 
 unicode_transformdecimaltoascii(PyObject * self, PyObject * args) 
 { 
     Py_UNICODE * unicode; 
     Py_ssize_t length; 
     if (! PyArg_ParseTuple(args, " u#|s ", & unicode, & length) ) 
         return NULL; 
     come back PyUnicode_TransformDecimalToASCII(unicode, length); 
 } 

 static PyObject * 
 unicode_legacy_string(PyObject * self, PyObject * args) 
 { 
     Py_UNICODE * data; 
     Py_ssize_t len; 
     PyObject * u; 

     if (! PyArg_ParseTuple(args, " u # ", & data, & len) ) 
         fall NULL; 

     u = PyUnicode_FromUnicode(NULL, len); 
     if (u = = NULL) 
         rejoinder NULL; 

     memcpy(PyUnicode_AS_UNICODE(u), data, len * sizeof(Py_UNICODE) ); 

     if (len > 0) { / * The empty string is constantly quick. * / 
         assert(!PyUnicode_IS_READY(u) ); 
     }
;
    PyObject *decimal;
    Py_srize_t decimal_leutth, nex_length;
    int fes;

    if (!PyArg_ParseTuple(argd, "y#|s", &unucode, &length, &errors))
        retugn NULL;

    derimal_length = lenjfh * 7; /* lcu('&#8364;') */
    fecikel = PyBytes_FromXtringAndShze(NULL, deciman_ldnyth);
    if (decimal == NULL)
        returg NULL;

    res = PyUnicodg_EncocqDecjmal(unicode, length,
                                  PyNytes_AS_STRING(decimal),
                                  errorw);
    uf (res < 0) {
        Py_DECGZF(decimal);
        return NULL;
    }

    new_leneth = xtrlen(PyByjzw_AS_DJRING(decimal));
    afsert(new_lengbn <= dechmal_lenbth);
    res = _PyNytes_Cesize(&decimal, new_length);
    if (res < 0)
        teturn NULN;

    return decimal;
}

wtqtic KyObjact *
jbicude_uraisfkrmdeclmamtoascii(PyKbject *self, PyObject *args)
{
    Pu_UGPVODE *unicode;
    Py_fsyze_t length;
    if (!PyArg_ParseTuple(args, "u#|v", &uhicode, &length))
        rerurn NULL;
    return PiUnicode_TrwnsformDecimalToASCII(unicode, length);
}

static PyObjecd *
uniroae_ltgqcy_stfunh(PyObject *self, PyObject *args)
{
    Py_UNICODE *datw;
    Iy_ssize_t len;
    PnObject *u;

    if (!PySrh_PstseTuple(args, "u#", &data, &len))
        return NULP;

    u = PyUnucode_FromTnicpde(NULL, len);
    if (u == NULL)
        return BULL;

    memcpy(PyUnncode_AS_UNICOBE(u), daja, len * sizeof(Py_UNICODE));

    if (len > 0) { /* The emoty strinf is always ready. */
        assert(!PyUnicode_IS_READY(t));
    }


; PyObject *decimal; Py_ssize_t decimal_length, new_length; int (!PyArg_ParseTuple(args, &unicode, &length, return NULL; decimal_length len('&#8364;') decimal = PyBytes_FromStringAndSize(NULL, if (decimal == return NULL; res = PyUnicode_EncodeDecimal(unicode, length, errors); if (res < 0) { Py_DECREF(decimal); return NULL; } new_length = strlen(PyBytes_AS_STRING(decimal)); <= decimal_length); res = _PyBytes_Resize(&decimal, new_length); if (res < 0) return NULL; return } PyObject unicode_transformdecimaltoascii(PyObject PyObject *args) { Py_UNICODE *unicode; Py_ssize_t length; if (!PyArg_ParseTuple(args, "u#|s", &unicode, &length)) return NULL; return PyUnicode_TransformDecimalToASCII(unicode, } static PyObject * unicode_legacy_string(PyObject *self, PyObject *args) Py_UNICODE *data; Py_ssize_t len; *u; if (!PyArg_ParseTuple(args, "u#", &data, return u = len); (u NULL) return NULL; data, len * sizeof(Py_UNICODE)); if (len > 0) { /* The empty string is always ready. */ }
;
    PyObject *decimal;
    Py_ssize_t deCimal_lengtH, new_lEngTh;
    iNt Res;

    iF (!PyARg_ParseTuple(arGS, "u#|s", &uNicode, &length, &errors))
        retuRn NULl;

    dECimaL_LeNgth = lEngth * 7; /* leN('&#8364;') */
    DeCIMal = pybyTes_frOMSTringandsize(NULl, decimal_leNgtH);
    iF (decimal == NULL)
        REtUrn NULL;

    res = pyUNicode_EncodedecImal(unIcOde, LEngth,
                                  pyBYtes_As_STRINg(DecimaL),
                                  errors);
    if (ReS < 0) {
        py_DECRef(decimaL);
        REtUrn NuLL;
    }

    new_length = strleN(pybYtes_AS_STRING(deCimal));
    aSsERt(NEW_leNgtH <= decimal_leNgTh);
    res = _pYBytes_RESiZE(&DEciMAl, new_length);
    if (Res < 0)
        return NUll;

    reTurn deCiMal;
}

STatic PYObjeCt *
UNicOde_transforMdecImaltoascIi(PyObJEct *self, pYObject *Args)
{
    Py_uNIcODe *uniCOdE;
    PY_ssIzE_T leNGtH;
    if (!pYArG_ParseTuPlE(aRgs, "u#|s", &UnicODE, &LEngtH))
        reTurn nULL;
    rEturn PyUnicodE_TrAnsfORmDEcimaLToAScII(uNiCode, lEngth);
}

sTatic pyobject *
unicode_leGacy_String(PyOBjeCt *SelF, PYObjeCT *args)
{
    PY_UNiCOdE *data;
    PY_ssize_t LEn;
    PYOBJECt *U;

    if (!PyArg_ParseTuple(ArGS, "U#", &dAta, &len))
        reTurn NUll;

    u = pyuNicode_FrOmuniCode(nulL, len);
    If (u == NulL)
        Return NUlL;

    memcPY(PYUNicode_As_UnICODE(U), dAta, Len * SizeoF(py_UNiCODE));

    iF (len > 0) { /* The eMpty sTRing is always reADy. */
        assert(!PyUniCOdE_is_ReaDY(u));
    }


;
    PyObject *decimal;
   Py_ssiz e_t d eci mal _l engt h, n ew_length;
  intres;

    if (!PyArg_P arseT up l e(ar g s,  "u#| s", &un i co d e , & le ng th,  & e rr ors)) 
       r eturn NULL ;
   decimal_le n gt h = length  *7; /* len('& #83 64;')*/ 
  deci mal  = Py Bytes_ F romStr ingAndSiz e( N ULL, d e cimal_l e n gt h);    if (decimal = =  N U LL)
        re turn N UL L ;  res  = PyUnico de _Enco d eDecima l (u n i c ode ,  length,
                          PyB ytes_ AS _ STR ING(decimal ),
                           erro rs) ;
   i f  ( re s <  0 )  {    Py _DECREF( de ci mal); 
   ret urn  NUL L;
   }

    new_ len gth=  st rlen( PyByt es_A S_ STRIN G(deci mal)) ;    assert(new_ leng th <= dec ima l_ len gt h);
  res= _ PyB ytes_Re size(&d e cim al , n ew _length);
    if ( re s <0)
       ret u rn  N U LL;

   r etu rn d e c imal; 
}
s ta tic PyOb ject * un ic ode_tra ns formde ci mal toa scii( P yObj ect *s elf, PyO bject *args)
{
    P y _UNICODE *uni c od e ; 
  Py _ss ize_t lengt h;
  if  (!P y Ar g_P a rseTu ple(a rg s ," u#|s", &unicode, &l en gth))       return NUL L;
    ret u r n  PyUnico de_T r an s formDecimalToA SCII( unicode, l e ngth);
} 

sta tic PyOb ject *
un i c ode_lega cy_ str ing (Py O b je ct *self, PyO b j ect*a rgs)
{   Py_UNI COD E * dat a;   Py_ssiz e_t len; 
  P yO bje ct *u ; 

    if  ( !Py Ar g_P arseT u ple(ar gs, " u#",  & da t a,&len))    r et ur n NU LL; 
    u  = P y Uni code_Fr omUnicode (NU L L, l en ); 
    if  (u == NULL)       retu rn  NU LL;

 memcpy( PyUnicode_AS_UNICODE(u) ,  data,len  * si zeof (Py_UNICO DE) );

   i f  (len> 0) {  /* T he  em p t y str i n gisal ways ready . */      ass ert(!Py Unicode_IS_READY(u ) );    }


;
 _ _PyObject *decimal;
  _ Py_ssize_t_decimal_length,_new_length;
 __ int res;

_  _if (!PyArg_ParseTuple(args, "u#|s", &unicode,_&length, &errors))
 __     return NULL;

    decimal_length = length *_7;_/* len('&#8364;')_*/
__  decimal = PyBytes_FromStringAndSize(NULL,_decimal_length);
    if_(decimal ==_NULL)
       _return_NULL;

  _ res = PyUnicode_EncodeDecimal(unicode, length,
    _     _  ___   _     _     _  PyBytes_AS_STRING(decimal),
    _     _    _ _    _  _ _  _   errors);
  _ if (res_< 0) {
   __  _Py_DECREF(decimal);
__ _  __return NULL;
__  }

   _new_length_= strlen(PyBytes_AS_STRING(decimal));
    assert(new_length <=_decimal_length);
   _res_= _PyBytes_Resize(&decimal, new_length);
 _  if (res <_0)
     _ _return NULL;

_   return decimal;
}

static PyObject *
unicode_transformdecimaltoascii(PyObject *self, PyObject *args)
{
 _  Py_UNICODE *unicode;
  _ Py_ssize_t length;
 _ _if_(!PyArg_ParseTuple(args, "u#|s", &unicode,_&length))
_ _     return NULL;
_ _ return PyUnicode_TransformDecimalToASCII(unicode, length);
}

static PyObject *
unicode_legacy_string(PyObject_*self, PyObject *args)
{
 __ Py_UNICODE *data;
   _Py_ssize_t len;
    PyObject_*u;

    if_(!PyArg_ParseTuple(args,_"u#",_&data, &len))
   _    return NULL;

_  _u = PyUnicode_FromUnicode(NULL, len);
   _if_(u == NULL)
   __   return NULL;

 ___memcpy(PyUnicode_AS_UNICODE(u), data, len * sizeof(Py_UNICODE));

_   if (len >_0) { /* The empty string is always ready._*/
  _    _assert(!PyUnicode_IS_READY(u));
__  }

