As Nathan points out in the comments, using a Gamma node with the magic "2.2" value is only approximate because sRGB<->Linear conversions involve a power function.
As I needed a more exact conversion for my specific use case (I'm encoding bitmasks as colours into my vertexes as an optimisation for my game), I have taken the blender source that was linked (https://github.com/blender/blender/blob/594f47ecd2d5367ca936cf6fc6ec8168c2b360d0/source/blender/blenlib/intern/math_color.c) and converted it to blender nodes for your convenience.
Converting sRGB to Linear
Blender's implementation in C
float srgb_to_linearrgb(float c)
{
if (c < 0.04045f) {
return (c < 0.0f) ? 0.0f : c * (1.0f / 12.92f);
}
return powf((c + 0.055f) * (1.0f / 1.055f), 2.4f);
}
Material node equivalent
Converting Linear to sRGB
Blender's implementation in C
float linearrgb_to_srgb(float c)
{
if (c < 0.0031308f) {
return (c < 0.0f) ? 0.0f : c * 12.92f;
}
return 1.055f * powf(c, 1.0f / 2.4f) - 0.055f;
}
Material node equivalent
I've implemented both of these as node groups in my project. Here's a minimal use case of it in action, which will read my vertex colour's red channel and convert it to the range 0-255, which matches my setup in Unreal Engine:
Note that some of the numbers in the screenshots have been truncated in blender, if implementing again yourself, you may have to manually punch in 1/12.92
/or whatever to get closer to my implementation's results.
Also note that I haven't tested these blender nodes extensively -- I am no expert with this software, but figured this would be a helpful starting point for artists to interpret the C equivalent for conversions.