Subversion Repositories tpanel

Rev

Rev 456 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 456 Rev 474
Line 1... Line 1...
1
/*
1
/*
2
 * Copyright (C) 2020 to 2022 by Andreas Theofilu <andreas@theosys.at>
2
 * Copyright (C) 2020 to 2024 by Andreas Theofilu <andreas@theosys.at>
3
 *
3
 *
4
 * This program is free software; you can redistribute it and/or modify
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
7
 * (at your option) any later version.
Line 989... Line 989...
989
    }
989
    }
990
 
990
 
991
    return num;
991
    return num;
992
}
992
}
993
 
993
 
-
 
994
unsigned char *uint16ToBytes(uint16_t num, unsigned char* bytes)
-
 
995
{
-
 
996
    unsigned char *bt = bytes;
-
 
997
 
-
 
998
    if (!bytes)
-
 
999
        bt = new unsigned char[2];
-
 
1000
 
-
 
1001
    *bt = num >> 8;
-
 
1002
    *(bt+1) = num;
-
 
1003
    return bt;
-
 
1004
}
-
 
1005
 
-
 
1006
unsigned char * uint32ToBytes(uint16_t num, unsigned char* bytes)
-
 
1007
{
-
 
1008
    unsigned char *bt = bytes;
-
 
1009
 
-
 
1010
    if (!bytes)
-
 
1011
        bt = new unsigned char[4];
-
 
1012
 
-
 
1013
    *bt = num >> 24;
-
 
1014
    *(bt+1) = num >> 16;
-
 
1015
    *(bt+2) = num >> 8;
-
 
1016
    *(bt+3) = num;
-
 
1017
    return bt;
-
 
1018
}
-
 
1019
 
994
string UnicodeToUTF8(const wstring& ws)
1020
string UnicodeToUTF8(const wstring& ws)
995
{
1021
{
996
    string s;
1022
    string s;
997
 
1023
 
998
    for(size_t i = 0; i < ws.size(); ++i)
1024
    for(size_t i = 0; i < ws.size(); ++i)