GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — livecode/libscript/src/module-encoding.cpp at develop · livecode/livecode
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
Expand file tree/ Copy pathmodule-encoding.cppMore file actions 265 lines (197 loc) · 7.89 KB / Copy pathmodule-encoding.cppFile metadata and controls265 lines (197 loc) · 7.89 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 /* Copyright (C) 2003-2015 LiveCode Ltd. This file is part of LiveCode. LiveCode is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License v3 as published by the Free Software Foundation. LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with LiveCode. If not see <http://www.gnu.org/licenses/>. */ #include <foundation.h> #include "foundation-auto.h" #include "foundation-filters.h" void MCEncodingEvalEncodedOfValue(MCValueRef p_target, MCDataRef& r_output) { } void MCEncodingEvalDecodedOfValue(MCDataRef p_target, MCValueRef& r_output) { } void MCEncodingExecCompress(MCDataRef& x_target) { MCAutoDataRef t_compressed; if (MCFiltersCompress(x_target, &t_compressed)) { MCValueAssign(x_target, *t_compressed); return; } // ctxt . Throw(); } void MCEncodingExecDecompress(MCDataRef& x_target) { MCAutoDataRef t_decompressed; if (MCFiltersDecompress(x_target, &t_decompressed)) { MCValueAssign(x_target, *t_decompressed); return; } // ctxt . Throw(); } void MCEncodingExecEncodeUsingBase64(MCDataRef p_target, MCStringRef& r_output) { if (MCFiltersBase64Encode(p_target, r_output)) return; // ctxt . Throw(); } void MCEncodingExecDecodeUsingBase64(MCStringRef p_target, MCDataRef& r_output) { if (MCFiltersBase64Decode(p_target, r_output)) return; // ctxt . Throw(); } void MCEncodingExecEncodeUsingBinary(MCStringRef p_target, MCStringRef p_format, MCDataRef& r_output) { // TODO: Move binary encode/decode to foundation // Does this take a list? // ctxt . Throw(); } void MCEncodingExecDecodeUsingBinary(MCDataRef p_target, MCStringRef p_format, MCStringRef& r_output) { // TODO: Move binary encode/decode to foundation // Does this take a list? // ctxt . Throw(); } //////////////////////////////////////////////////////////////////////////////////////////////////// void MCEncodingExecEncodeUsingUTF8(MCStringRef p_target, MCDataRef& r_output) { if (MCStringEncode(p_target, kMCStringEncodingUTF8, false, r_output)) return; // ctxt . Throw(); } void MCEncodingExecDecodeUsingUTF8(MCDataRef p_target, MCStringRef& r_output) { if (MCStringDecode(p_target, kMCStringEncodingUTF8, false, r_output)) return; // ctxt . Throw(); } void MCEncodingExecEncodeUsingUTF16(MCStringRef p_target, MCDataRef& r_output) { if (MCStringEncode(p_target, kMCStringEncodingUTF16, false, r_output)) return; // ctxt . Throw(); } void MCEncodingExecDecodeUsingUTF16(MCDataRef p_target, MCStringRef& r_output) { if (MCStringDecode(p_target, kMCStringEncodingUTF16, false, r_output)) return; // ctxt . Throw(); } void MCEncodingExecEncodeUsingUTF32(MCStringRef p_target, MCDataRef& r_output) { if (MCStringEncode(p_target, kMCStringEncodingUTF32, false, r_output)) return; // ctxt . Throw(); } void MCEncodingExecDecodeUsingUTF32(MCDataRef p_target, MCStringRef& r_output) { if (MCStringDecode(p_target, kMCStringEncodingUTF32, false, r_output)) return; // ctxt . Throw(); } void MCEncodingExecEncodeUsingASCII(MCStringRef p_target, MCDataRef& r_output) { if (MCStringEncode(p_target, kMCStringEncodingASCII, false, r_output)) return; // ctxt . Throw(); } void MCEncodingExecDecodeUsingASCII(MCDataRef p_target, MCStringRef& r_output) { if (MCStringDecode(p_target, kMCStringEncodingASCII, false, r_output)) return; // ctxt . Throw(); } void MCEncodingEvalURLEncoded(MCStringRef p_target, MCStringRef& r_output) { if (MCFiltersUrlEncode(p_target, r_output)) return; // ctxt . Throw(); } void MCEncodingEvalURLDecoded(MCStringRef p_target, MCStringRef& r_output) { if (MCFiltersUrlDecode(p_target, r_output)) return; // ctxt . Throw(); } //////////////////////////////////////////////////////////////////////////////////////////////////// #ifdef _TEST extern void log(const char *module, const char *test, bool result); #define log_result(test, result) log("ENCODING MODULE", test, result) void MCEncodingRunTests() { /* void MCEncodingEvalEncodedOfValue(MCValueRef p_target, MCDataRef& r_output) void MCEncodingEvalDecodedOfValue(MCDataRef p_target, MCValueRef& r_output) void MCEncodingExecEncodeUsingBase64(MCDataRef p_target, MCStringRef& r_output) void MCEncodingExecDecodeUsingBase64(MCStringRef p_target, MCDataRef& r_output) void MCEncodingExecEncodeUsingBinary(MCStringRef p_target, MCStringRef p_format, MCDataRef& r_output) void MCEncodingExecDecodeUsingBinary(MCDataRef p_target, MCStringRef p_format, MCStringRef& r_output) void MCEncodingExecEncodeUsingUTF8(MCStringRef p_target, MCDataRef& r_output) void MCEncodingExecDecodeUsingUTF8(MCDataRef p_target, MCStringRef& r_output) void MCEncodingExecEncodeUsingUTF16(MCStringRef p_target, MCDataRef& r_output) void MCEncodingExecDecodeUsingUTF16(MCDataRef p_target, MCStringRef& r_output) void MCEncodingExecEncodeUsingUTF32(MCStringRef p_target, MCDataRef& r_output) void MCEncodingExecDecodeUsingUTF32(MCDataRef p_target, MCStringRef& r_output) void MCEncodingExecEncodeUsingASCII(MCStringRef p_target, MCDataRef& r_output) void MCEncodingExecDecodeUsingASCII(MCDataRef p_target, MCStringRef& r_output) */ /* void MCEncodingExecCompress(MCDataRef& x_target) void MCEncodingExecDecompress(MCDataRef& x_target) */ MCAutoDataRef t_data; MCDataCreateWithBytes((const byte_t *)"hello world", 11, &t_data); MCDataRef t_to_compress; MCDataMutableCopy(*t_data, t_to_compress); MCEncodingExecCompress(t_to_compress); log_result("compress changes data", !MCDataIsEqualTo(*t_data, t_to_compress)); MCEncodingExecDecompress(t_to_compress); log_result("compress/decompress round trip", MCDataIsEqualTo(*t_data, t_to_compress)); MCValueRelease(t_to_compress); MCDataRef t_empty; MCDataMutableCopy(kMCEmptyData, t_empty); MCEncodingExecCompress(t_empty); MCEncodingExecDecompress(t_empty); log_result("compress/decompress empty", MCDataIsEqualTo(t_empty, kMCEmptyData)); MCValueRelease(t_empty); /* void MCEncodingEvalURLEncoded(MCStringRef p_target, MCStringRef& r_output) void MCEncodingEvalURLDecoded(MCStringRef p_target, MCStringRef& r_output) */ MCStringRef t_test_a, t_test_b; MCStringRef t_test_c, t_test_d; t_test_a = MCSTR(" "); t_test_b = MCSTR("+"); t_test_c = MCSTR("?"); t_test_d = MCSTR("%3F"); MCAutoStringRef t_encoded, t_decoded; MCAutoStringRef t_encoded2, t_decoded2; MCEncodingEvalURLEncoded(t_test_a, &t_encoded); log_result("url encode space", MCStringIsEqualTo(*t_encoded, t_test_b, kMCStringOptionCompareCaseless)); MCEncodingEvalURLEncoded(t_test_c, &t_encoded2); log_result("url encode ?", MCStringIsEqualTo(*t_encoded2, t_test_d, kMCStringOptionCompareCaseless)); MCEncodingEvalURLDecoded(t_test_b, &t_decoded); log_result("url decode +", MCStringIsEqualTo(*t_decoded, t_test_a, kMCStringOptionCompareCaseless)); MCEncodingEvalURLDecoded(t_test_d, &t_decoded2); log_result("url decode %3F", MCStringIsEqualTo(*t_decoded2, t_test_c, kMCStringOptionCompareCaseless)); } #endif //////////////////////////////////////////////////////////////////////////////////////////////////// extern "C" bool com_livecode_encoding_Initialize(void) { return true; } extern "C" void com_livecode_encoding_Finalize(void) { } //////////////////////////////////////////////////////////////////////////////////////////////////// |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |