Buchempfehlung
MySQL kurz & gut
MySQL kurz & gut
Das preiswerte Taschen- buch stellt MySQL-rele- vante Inhalte systematisch und knapp dar, sodass es sich optimal zum Nach- schlagen beim Pro- grammieren eignet. [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

fb:porticula NoPaste

Info
Info / Hilfe
Liste
Übersicht / Liste
Neu
Datei hochladen
Suche
Quellcode suchen
Download
Dateidownload

UTF8/ASCII Konvertierung (FB-Intern)

Uploader:MitgliedEternal_Pain
Datum/Zeit:07.08.2007 20:20:16

Declare Function myCharToUTF Cdecl Alias "fb_CharToUTF" ( Byval encod As Integer, _
                                                          Byval src As Zstring Ptr, _
                                                          Byval chars As Integer, _
                                                          Byval dst As Any Ptr, _
                                                          Byval bytes As Integer Ptr ) As Any Ptr

Declare Function myUTFToChar Cdecl Alias "fb_UTFToChar" ( Byval encod As Integer, _
                                                          Byval src As Any Ptr, _
                                                          Byval dst As Zstring Ptr, _
                                                          Byval chars As Integer Ptr ) As Zstring Ptr


Declare Function ASCII2UTF (Byval ConvertString As String) As String
Declare Function UTF2ASCII (Byval ConvertString As String) As String

/'
    ASCII2UTF
    
    Syntax    : ASCII2UTF (MeinText[$])
    Typ       : Funktion
    Kategorie : Stringmanipulation
    
    Wandelt einen "String" mit ASCII Inhalt zu einen "String" mit UTF8 Inhalt um.
'/


Function ASCII2UTF (Byval ConvertString As String) As String
   Dim As Zstring Ptr pZ
   Dim As Zstring Ptr pR
   Dim As Integer     lS
   Dim As Integer Ptr pI

   lS = Len(ConvertString)
   pI = Callocate(1)
   pR = Callocate(4 * lS)
   pZ = Strptr(ConvertString)

   myCharToUTF( 1, pZ, lS, pR, pI)

   pR = Reallocate(pR, *pI)
   Function = *pR

   Deallocate pI
   Deallocate pR
End Function

/'
    ASCII2UTF
    
    Syntax    : UTF2ASCII (MeinText[$])
    Typ       : Funktion
    Kategorie : Stringmanipulation
    
    Wandelt einen "String" mit UTF8 Inhalt zu einen "String" mit ASCII Inhalt um.
'/


Function UTF2ASCII (Byval ConvertString As String) As String
   Dim As Zstring Ptr pZ
   Dim As Zstring Ptr pR
   Dim As Integer     lS
   Dim As Integer Ptr pI

   lS = Len(ConvertString)
   pI = @lS'Callocate(1)
   pR = Callocate(4 * lS)
   pZ = Strptr(ConvertString)

   myUTFToChar( 1, pZ, pR, pI)

   pR = Reallocate(pR, *pI)
   Function = *pR

   Deallocate pI
   Deallocate pR
End Function