Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
44 user(s) are online (23 user(s) are browsing Forums)

Members: 0
Guests: 44

more...

Support us!

Headlines

Report message:*
 

Re: Porting to AmigaOS4 thread

Subject: Re: Porting to AmigaOS4 thread
by jabirulo on 2020/11/22 10:43:37

@Raziel

Ok, here is code "converted", dunnot if it will crash/GR or make your system burn

#if defined(__amigaos4__) && defined(USE_SYSDIALOGS) 

#include "backends/dialogs/amigaos/amigaos-dialogs.h" 

#include "common/config-manager.h" 
#include "common/encoding.h" 


#include <proto/codesets.h> 
//#include <libraries/codesets.h> 

#include <proto/asl.h> 
#include <proto/dos.h> 
#include <proto/exec.h> 

#include <cstring>
#include <cstdlib>


struct Library *CodesetsBase NULL;
struct CodesetsIFace *ICodesets NULL;



char *AmigaOSDialogManager::utf8ToLocal(char *in) { 

    if (!
in) { 
        return 
strdup(""); 
    } 

    
CodesetsBase IExec->OpenLibrary("codesets.library"6); 
    if (
CodesetsBase) { 

ICodesets = (CodesetsIFace *)IExec->GetInterface(CodesetsBase"main"1LNULL);

struct codeset *srcmib ICodesets->CodesetsFind("ISO-8859-1"CSA_FallbackToDefault,FALSETAG_DONE);

        
//LONG dstmib = CSA_DestCodeset(NULL, 0); 
        
struct codeset *dstmib ICodesets->CodesetsFind("UTF-8"CSA_FallbackToDefault,FALSETAG_DONE);

        
//if (dstmib != CS_MIBENUM_INVALID) { 
        
if(dstmib != NULL) {
            
//LONG dstlen = FSGetByteSize((APTR)in, -1, CS_MIBENUM_UTF_8, dstmib); 
            
ULONG dstlen ICodesets->CodesetsStrLen(inTAG_END);

            
char *out = (char *)malloc(dstlen 1); 
            if (
out) { 
                if( (
out=ICodesets->CodesetsConvertStr(CSA_SourceCodesetsrcmib,
                                                       
CSA_DestCodesetdstmib,
                                                       
CSA_Source,      in,
                                                       
//CSA_DestLenPtr,  &dstlen,
                                                      
TAG_DONE)) != NULL) {
                
//if (ConvertTagList((APTR)in, -1, (APTR)out, -1, CS_MIBENUM_UTF_8, dstmib, NULL) != -1) { 
IExec->DropInterface( (struct Interface *)ICodesets );
ICodesets NULL;
        
IExec->CloseLibrary(CodesetsBase);
CodesetsBase NULL;
                    return 
out
                }
                
free(out); 
            } 
        } 
IExec->DropInterface( (struct Interface *)ICodesets );
ICodesets NULL;
        
IExec->CloseLibrary(CodesetsBase);
CodesetsBase NULL;
    } 

    return 
strdup(in); 
}


Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project