# Bi-color nodes and special characters

**URL:** <https://forum.graphviz.org/t/bi-color-nodes-and-special-characters/252>\
**Category:** Help\
**Created:** [July 11, 2020, 3:35am UTC](https://forum.graphviz.org/t/bi-color-nodes-and-special-characters/252 "2020-07-11T03:35:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![milliliter](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@milliliter](https://forum.graphviz.org/u/milliliter)\
**Post date:** [July 11, 2020, 3:35am UTC](https://forum.graphviz.org/t/bi-color-nodes-and-special-characters/252/1 "2020-07-11T03:35:29Z")

</div>

I’m using dot to re-create handwritten trees, and there are two little things that would make it better:

1. Can I change the text color within a node? (Edit: Yes! with [HTML-like labels](https://graphviz.gitlab.io/_pages/doc/info/shapes.html#html).)
2. I want to add special characters, like schwa and vowels with macrons. (I checked HTML resources, and it doesn’t look like it has encodings for those characters.) Are there codes for special characters besides the three line-breaks? And if so, do I have to choose between special characters and HTML-like labels?

---

<div class="post-metadata">

**Author:** ![mark](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/mark/32/84_2.png) [@mark](https://forum.graphviz.org/u/mark)\
**Post date:** [July 11, 2020, 3:52am UTC](https://forum.graphviz.org/t/bi-color-nodes-and-special-characters/252/2 "2020-07-11T03:52:25Z")

</div>

For the special characters, can you put them directly in your source file? Should “just work” if the source file is UTF8 encoded

---

<div class="post-metadata">

**Author:** ![milliliter](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@milliliter](https://forum.graphviz.org/u/milliliter)\
**Post date:** [July 11, 2020, 7:59pm UTC](https://forum.graphviz.org/t/bi-color-nodes-and-special-characters/252/3 "2020-07-11T19:59:04Z")

</div>

That would be great. I’m gonna need specifics; I’ve tried a lot of things and none of them work. What (Windows) program do I use to edit the source file and how do I make sure it’s a UTF8 format?

---

<div class="post-metadata">

**Author:** ![steveroush](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@steveroush](https://forum.graphviz.org/u/steveroush)\
**Post date:** [July 12, 2020, 4:06pm UTC](https://forum.graphviz.org/t/bi-color-nodes-and-special-characters/252/4 "2020-07-12T16:06:27Z")

</div>

```
digraph nota {
  rankdir=LR
  { rank=same
  A [label="Entered using Notepad"]
  B [label="schwa using html encoding: &#399; and &#601;"]

  D [label="Masron examples: &#256; &#275; &#363; &#481; &#1250; "]
x1[label="https://en.wikipedia.org/wiki/%C6%8F"]
x2[label="https://en.wikipedia.org/wiki/Macron_(diacritic)"]
  }
}

```

Produces this:  
 ![nonascii1](https://global.discourse-cdn.com/graphviz/original/1X/a0f1bf065c4a55a145fecbceb99d6bc66215077a.png)

---

<div class="post-metadata">

**Author:** ![erg](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/erg/32/34_2.png) [@erg](https://forum.graphviz.org/u/erg)\
**Post date:** [July 13, 2020, 8:33pm UTC](https://forum.graphviz.org/t/bi-color-nodes-and-special-characters/252/5 "2020-07-13T20:33:33Z")

</div>

As noted, you can use special, non-ascii characters without using HTML-like labels. You can use the UTF-8 encoding explicitly, but as some of the bytes are not ascii, this can be cumbersome depending on the text editor you use. You can avoid non-ascii characters entirely either by using the numeric representation as shown by steveroush above or. if available, a descriptive form. For example, lower-case beta can be represented as either `&#946;` or `&beta;` . See the Character Encoding section in the [dot lang page](https://www.graphviz.org/doc/info/lang.html).

Note that, by default, Graphviz assumes the input character encoding is UTF-8. The programs can usually infer if this isn’t the case and report it. Also note that for all this to work, the font used in rendering must supply the glyphs you want.

---

<div class="post-metadata">

**Author:** ![milliliter](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@milliliter](https://forum.graphviz.org/u/milliliter)\
**Post date:** [July 23, 2020, 12:05am UTC](https://forum.graphviz.org/t/bi-color-nodes-and-special-characters/252/6 "2020-07-23T00:05:46Z")

</div>

For whatever reason, pasting characters into Notepad and saving works now. The references on this page also work: [Character Entities | Graphviz](https://www.graphviz.org/doc/char.html) (That page links to two pages on [w3.org](http://w3.org): the first has the same information, but the second (“an official version of this reference”) is not the same at all and not useful for GV.)

At any rate, problem solved! Thanks for all your help.

---

<div class="post-metadata">

**Author:** ![mark](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/mark/32/84_2.png) [@mark](https://forum.graphviz.org/u/mark)\
**Post date:** [July 23, 2020, 9:14am UTC](https://forum.graphviz.org/t/bi-color-nodes-and-special-characters/252/7 "2020-07-23T09:14:34Z")

</div>

> [@milliliter](#):
>
> The references on this page also work: [Character Entities | Graphviz](https://www.graphviz.org/doc/char.html) (That page links to two pages on [w3.org](http://w3.org): the first has the same information, but the second (“an official version of this reference”) is not the same at all and not useful for GV.)

Thanks for the feedback. I’ve removed the second link: [Update char.html - remove link to list of named chars (!182) · Merge requests · graphviz / graphviz.gitlab.io · GitLab](https://gitlab.com/graphviz/graphviz.gitlab.io/-/merge_requests/182)

---

<div class="post-metadata">

**Author:** ![mark](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/mark/32/84_2.png) [@mark](https://forum.graphviz.org/u/mark)\
**Post date:** [July 23, 2020, 9:14am UTC](https://forum.graphviz.org/t/bi-color-nodes-and-special-characters/252/8 "2020-07-23T09:14:45Z")

</div>

I wonder if we should stop documenting these entity references and encourage UTF-8 instead, now that UTF-8 is near-universal.
