Giter Club home page Giter Club logo

Comments (4)

tanner0101 avatar tanner0101 commented on May 10, 2024

If you could submit a test case where this fails, that would help a ton.

Otherwise I will investigate this on the next update.

from mysql-kit.

collinhundley avatar collinhundley commented on May 10, 2024

Here's how to reproduce the issue:

let mysql = try! MySQL.Database(...)
let myString = "È" // Unicode #200
try! mysql.execute("INSERT INTO mytable (myfield) VALUES (?)", [.string(myString)], nil)

This crashes at the following line in Bind.swift:

buffer[i] = Char(byte)

Because it's attempting to cast a decimal value of 200 into an Int8.

from mysql-kit.

collinhundley avatar collinhundley commented on May 10, 2024

UPDATE: Sorry to keep pestering about this, but I believe it's a big flaw in this library that should be addressed. I had a little more time to dig into it today, and I believe that the solution is simple.

I believe that Char should be changed to be a typealias for UInt8. The utf8 property of Swift's String returns a UTF8View, which itself is an array of unsigned 8-bit integers. The documentation isn't clear about this, but after some experimentation I've come to the conclusion that the integers are indeed unsigned, which is why we were experiencing crashes when handling any Unicode characters containing a byte larger than 127.

Making this change allows the package to be fully compatible with all Unicode characters.

from mysql-kit.

collinhundley avatar collinhundley commented on May 10, 2024

Fixed with PR #27

from mysql-kit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.