| 553 | |
| 554 | #ifndef mxCESU8 |
| 555 | void fx_ArrayBuffer_fromString(txMachine* the) |
| 556 | { |
| 557 | txSize length = 0; |
| 558 | if (mxArgc < 1) |
| 559 | mxTypeError("no argument"); |
| 560 | |
| 561 | txString c = fxToString(the, mxArgv(0)); |
| 562 | txInteger nulls = 0; |
| 563 | while (1) { |
| 564 | uint8_t b = (uint8_t)c_read8(c++); |
| 565 | if (!b) break; |
| 566 | |
| 567 | length += 1; |
| 568 | if ((0xc0 == b) && (0x80 == (uint8_t)c_read8(c))) |
| 569 | nulls += 1; |
| 570 | } |
| 571 | |
| 572 | fxConstructArrayBufferResult(the, mxThis, length - nulls); |
| 573 | if (!nulls) |
| 574 | c_memcpy(mxResult->value.reference->next->value.arrayBuffer.address, mxArgv(0)->value.string, length); |
| 575 | else { |
| 576 | txString c = mxArgv(0)->value.string, end = c + length; |
| 577 | txByte *out = mxResult->value.reference->next->value.arrayBuffer.address; |
| 578 | while (c < end) { |
| 579 | uint8_t b = (uint8_t)c_read8(c++); |
| 580 | if ((0xc0 == (uint8_t)b) && (0x80 == (uint8_t)c_read8(c))) { |
| 581 | b = 0; |
| 582 | c += 1; |
| 583 | } |
| 584 | *out++ = b; |
| 585 | } |
| 586 | } |
| 587 | } |
| 588 | #endif |
| 589 | |
| 590 | void fx_ArrayBuffer_isView(txMachine* the) |
nothing calls this directly
no test coverage detected