Let $\omega$ be the set of natural numbers. $2^\omega$ is the Cantor space.
Suppose $K$, $L \subset 2^\omega$ are compact, and there is an isometry $f: K \to L$. Then how could one extend $f$ to an isometry from $2^\omega$ to $2^\omega$? Here we are considering $2^\omega$ with the minimum difference metric, which gives the standard product topology; i.e.
$ d(x,y) = 2^{-\min \{ n : x(n) \neq y(n) \}}. $
When $u$ is a finite binary word, $u\cdot 2^\omega$ means the interval of $2^\omega$ formed by infinite words with prefix $u$ ($\cdot$ denotes word concatenation).
Let $A_{fin}$ be the set of finite prefixes of $A\subseteq 2^\omega$.
We say that $F: A_{fin}\to B_{fin}$ is an isometry if:
Side-note: When $A_{fin}=B_{fin}$ (or more generally, when the multiset of word lengths of $A_{fin}$ and $B_{fin}$ coincide), the last condition can also be replaced by "$F$ is bijective". The first condition then becomes redundant.
Proof:
Side-note: this also gives the following statement, which was not a priori obvious:
Proof: We just have to extend an isometry $F:A_{fin}\to B_{fin}$. When $u$ is non-empty, let $\sigma_F(u)$ be the last symbol of $F(u)$. We have that $\sigma:\{0,1\}^+\to\{0,1\}$ is the last symbol of an isometry $(2^\omega)_{fin}\to (2^\omega)_{fin}$ if and only if $\sigma(x1)=\neg \sigma(x0)$. So we can define $$\sigma(x0)=\begin{cases} \sigma_F(x0) & x0\in A_{fin}\\ \neg\sigma_F(x1) & x1\in A_{fin}\\ 0 & \text{else} \end{cases}$$ so that the relations $\sigma(x1)=\neg \sigma(x0)$ and $G(ua)=G(u)\sigma(ua)$ uniquely define an isometry $G: (2^\omega)_{fin}\to (2^\omega)_{fin}$. $G$ extends $F$, so the isometry $g: 2^\omega\to 2^\omega$ extends $f$.