Filter by emoji in dataview

Hey guys, thought I’d share this little bit with you.
I organize my tags with emojis everywhere. I like the visuals.

So for every input I have (books I read, blog posts, podcasts, etc.) I have an emoji for the input and then for the status (green: read, yellow: in process, red: to read)

So in the end, it looks like that:
:inbox_tray:/:memo:/:red_circle: (for an article in the reading list, unread yet)
:inbox_tray:/:studio_microphone:/:green_circle: ( for a podcast I processed)

Now, I wanted to create a view of “reading list” to show me all the items that are red.

It turned out to be more difficult than expected - as emojis are very problematic with dataview.

The only solution I found, was to turn the emoji text to unicode representation string and then check if I have the expected part.
For any future tinkerer, this is my solution:

function toUnicode(str) {
  return str.split('').map(function (value, index, array) {
    var temp = value.charCodeAt(0).toString(16).toUpperCase();
    if (temp.length > 2) {
      return '\\u' + temp;
    }
    return value;
  }).join('');
}


let pages = dv.pages('-"_Templates"')

let unprocessed = []
for (let page of pages) {
  if (!page.file.etags[0]) { continue; }
  if (page.type !== "article") { continue; }
  
  let unicode_tags_string = toUnicode(page.file.etags[0]);
  if(unicode_tags_string.includes("DD34")) {
  	unprocessed.push(page)
  }
}
unprocessed = dv.array(unprocessed)

dv.table(["File", "Tagsssss"], unprocessed.map(k => [k.file.link, k.tags]))

strange… i’ve had this working since dataview came out as a work around because the emoji only work in the where clause not the from clause:

Input:

table tags, file.ctime.year as CY, file.ctime.month as CM, file.ctime.day as CD, file.mtime.year as MY, file.mtime.month as MM, file.mtime.day as MD
from ""
where tags = "🧠️/📝️/🌱️"
sort file.ctime asc

Output:


But now even that has been fixed:

table tags, file.ctime.year as CY, file.ctime.month as CM, file.ctime.day as CD, file.mtime.year as MY, file.mtime.month as MM, file.mtime.day as MD
from #🧠️/📝️/🌱️
sort file.ctime asc

2 Likes

Could be a system difference?
I’m on a windows machine

probably, macOS here

@snird had the same problem. In my case it was caused by the Twitter Emoji Option from the Emoji Toolbar Plugin. After I disabled that option everything worked as expected.