Code Monkey home page Code Monkey logo

Comments (4)

bjrnt avatar bjrnt commented on August 20, 2024 1

@drgrib
I had trouble processing non-ASCII input in my Alfred workflows too, and it turns out it is due to UTF-8 normalization. It is fully possible to search for UTF-8 input as long as you perform NFC normalization on it first.

This is really tricky to notice as the strings will look identical when you print them, but comparisons won't yield the expected result. For example, if I pass "björn" as the Alfred query:

utf8.GlyphsInString(os.Args[1]) => 6, because one extra is added due to the ¨ being recorded as a separate glyph
utf8.GlyphsInString("björn") => 5
os.Args[1] == "björn" => false, because the normalization is different

Here's quick fix in Go:

import (
    "golang.org/x/text/unicode/norm"
)

query := norm.NFC.String(os.Args[1])

from alfred-bear.

AlanRezende avatar AlanRezende commented on August 20, 2024

When using with latin chars like ç or ã its does not work too.

from alfred-bear.

drgrib avatar drgrib commented on August 20, 2024

The Go code will search for :

>> go run cmd/search/main.go "어"
{
    "items": [
        {
            "title": "ㅍㅏᄋ ᅵ 어 works",
            "subtitle": "#tech",
            "arg": "B6AA2EED-C378-4759-B7F7-B2618A90AC13-51237-00037885D409A198",
            "valid": true
        }
    ]
}

But it appears that Alfred won't send queries that contain it. I suspect Alfred's Script Filter code can only handle ASCII inputs and has an error that blanks out the query once it receives non-ASCII Unicode.

from alfred-bear.

drgrib avatar drgrib commented on August 20, 2024

Thanks @bjrnt. Fixed in #13.

from alfred-bear.

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.